daily pastebin goal
17%
SHARE
TWEET

Untitled

a guest Sep 14th, 2018 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. parent vs closest
  2. $('.button_30').click(function(){
  3.     $(this).closest('.portlet').find('.portlet_content').text("foo");
  4. });​
  5.    
  6. $('.button_30').click(function(){
  7.     $(this).parent('.portlet').find('.portlet_content').text("foo");
  8. });​
  9.    
  10. <div class="portlet portlet_30">
  11.  
  12.     <div class="portlet_header portlet_header_30">
  13.         header content here
  14.     </div>
  15.  
  16.     <div class="portlet_sub_header portlet_sub_header_30">
  17.         <input type="text" class="textbox_30" />
  18.     </div>
  19.  
  20.     <div class="portlet_content portlet_content_30">
  21.         results go here
  22.     </div>
  23.  
  24.     <div class="portlet_footer portlet_footer_30">
  25.         <input type="button" class="button_30" />
  26.     </div>
  27.  
  28. </div>
  29.  
  30. <div class="portlet portlet_30">
  31.  
  32.     <div class="portlet_header portlet_header_30">
  33.         header content here
  34.     </div>
  35.  
  36.     <div class="portlet_sub_header portlet_sub_header_30">
  37.         <input type="text" class="textbox_30 />
  38.     </div>
  39.  
  40.     <div class="portlet_content portlet_content_30">
  41.         results go here
  42.     </div>
  43.  
  44.     <div class="portlet_footer portlet_footer_30">
  45.         <input type="button" class="button_30" />
  46.     </div>
  47.  
  48. </div>
  49.    
  50. $('.button_30').click(function(){
  51.     $(this).parents('.portlet').find('.portlet_content').text("foo");
  52. });​
  53.    
  54. $('.button_30').click(function(){
  55.     $(this).parents('.portlet:eq(0)').find('.portlet_content').text("foo");
  56. });​
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top