.closest and .find in jQuery


/ Published in: jQuery
Save to your folder(s)

.closest and .find are very useful - surprised I haven't heard of them before.


Copy this code and paste it in your HTML
  1. // Expand Tables
  2. $(".expandTable").toggle(
  3. function(){
  4. $(this).closest('.tableSection').find('.tradeTable').fadeIn();
  5. $(this).closest('.tableSection').find('.arrow').html('↓');
  6. },
  7. function(){
  8. $(this).closest('.tableSection').find('.tradeTable').fadeOut();
  9. $(this).closest('.tableSection').find('.arrow').html('→');
  10. }
  11. );

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.