javascript - How to show an own text block when mouseover on a picture -
i learning html , want when move mouse picture, elephant not shown more. instead there box (without border) same size, inside box there text blue background. how should change code?
try :
$(document).ready(function() { $("td").mouseenter(function(){ $("img").css({display:"none"}); $(".txt").show(); $(this).css({verticalalign:"top",backgroundcolor:"blue"}) }).mouseleave(function(){ $("img").css({display:"block"}); $(".txt").hide(); $(this).css({backgroundcolor:""}) }) })
img { width: 200px; height: 200px; } td { width: 200px; height: 200px; } .txt { display: none; color: #fff; }
<table align='center'> <tr> <td> <img src="http://gdbaif.com/images/animal-clipart/animal-clipart-02.jpg"/> <span class="txt">this text</span> </td> </tr> </table> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
Comments
Post a Comment