mouseover style change with JQuery -


taking following html:

    <li>     <p>     <a href="#" class="link" ><img src="images/photo_cityguild_cropped.jpg" alt="education" title="education">     <span class="label">e d u c t o n</span>     </a>     </p>     </li> 

i want change class of <span> on event of user hovering on image link.

i haven't got use of jquery under belt , been while anyway, trying following:

$(".link").mouseover(function() {     $(this).find("span").addclass("label2");   }).mouseout(function(){     $(this).find("span").removeclass("label2");   }); 

could indicate me need correct doing nothing.

thanks,

edit updated solution.

implemented code instead:

$(".link").live("mouseover mouseout", function(event) {   if ( event.type == "mouseover" ) {     $(this).find("span").addclass("label2");   } else {     $(this).find("span").removeclass("label2");   } }); 

yes, problem method have called. should suggested above i.e. addclass , removeclass.

also, think can refactor code using hover event

 $(".link").hover(function() {   $(this).find("span").toggleclass("label2"); }); 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -