javascript - hover() jquery only work on first item? -


my js this

$('#link').hover(function(){                 $(this).find('.actionblck').css('opacity','0.85');             },function(){                 $(this).find('.actionblck').css('opacity','1');             });          }); 

and have html <a id='link' href=".$link." target='_blank'> within foreach loop. work first item got effect, why? inspect html, has multiple link id.

ids meant unique. can have 1 element id on page. classes, though, can duplicated. classes meant provide clustering , grouping of common elements. ids menat select single element.

    $('.link').hover(function(){             $(this).find('.actionblck').css('opacity','0.85');         },function(){             $(this).find('.actionblck').css('opacity','1');         });      }); 

with html <a class='link' href=".$link." target='_blank'> should work.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -