jQuery - this keyword

The code below will fadeout all div elements while clicking one div, what if we want to fadeout only clicked div?

1:  $(document).ready(function() {  
2:    $('div').click(function() {  
3:      $(this).fadeOut('slow');  
4:    });  
5:  });$(document).ready(function() {  
6:    $('div').click(function() {  
7:      $(this).fadeOut('slow');  
8:    });  
9:  });  

Use 'this' keyword to indicate the clicked element!
1:  $(document).ready(function() {  
2:    $('div').click(function() {  
3:      $(this).fadeOut('slow');  
4:    });  
5:  });$(document).ready(function() {  
6:    $('div').click(function() {  
7:      $(this).fadeOut('slow');  
8:    });  
9:  });  

No comments:

Post a Comment