Jquery show, hide function does not work -


jquery find function hide , show not work, wrong?

<script src="http://code.jquery.com/jquery-1.9.1.js"></script>    <script>         $('div').hover(function() {            $(this).find('.delete').show();         }, function() {            $(this).find('.delete').hide();         });   </script>   <div>     blah     <span class="delete">delete</span> </div> 

add document ready function script , work

  <script>       $(document).ready(function(){         $('div').hover(function() {            $(this).find('.delete').show();         }, function() {            $(this).find('.delete').hide();         });       });   </script> 

explanation:

you binding hover function div before div exists.
using document ready function, binding of function takes place when div available


Comments

Popular posts from this blog

android - net_scheduler holding wakelock -

sql - MySQL : Getting Entries from a many-to-many table -

java - Retrieving data from database using jsp (Hibernate + Spring + Maven) -