daily pastebin goal
8%
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var thumbLength = $('.thumb').length;                  
  2. for (var i = 0; i < thumbLength; i++) {
  3.  
  4.     $('#thumb-' + i).hover(
  5.         function () {
  6.             $('#img-' + i).addClass('hover');
  7.         },
  8.             $('#img-' + i).removeClass('hover');
  9.         }
  10.     );
  11. }
  12.    
  13. <ul>
  14.     <li class="thumb" id='#thumb-0'>Milk</li>
  15.     <li class="thumb" id='#thumb-1'>Bread</li>
  16.     <li class="thumb" id='#thumb-2'>Chips</li>
  17.     <li class="thumb" id='#thumb-3'>Socks</li>
  18.   </ul>
  19. <div class='img' id='#img-0'>Milk</div>
  20. <div class='img' id='#img-1'>Bread</div>
  21. <div class='img' id='#img-2'>Chips</div>
  22. <div class='img' id='#img-3'>Socks</div>
  23.    
  24. .hover{
  25.     color:green;
  26.     font-size: 20px;
  27. }
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