[jQuery] addClass on ahref link on the fly

[jQuery] addClass on ahref link on the fly


Hi
I've got a list of image with links and need to add a class on the fly on
the ahref link. The output is like that
<ul>
<li> http://www.site.com/ http://www.imageurl.com/img.png </li>
<li> http://www.site.com/ http://www.imageurl.com/img.png </li>
<li> http://www.site.com/ http://www.imageurl.com/img.png </li></ul>
and I want this (class="tooltip2") :
<ul>
<li> http://www.site.com/ http://www.imageurl.com/img.png </li>
<li> http://www.site.com/ http://www.imageurl.com/img.png </li>
<li> http://www.site.com/ http://www.imageurl.com/img.png </li></ul>
I need to do this because all is auto-generated I can only add this class
with jQuery. I tried different code but my knowledge isn't sufficient
jQuery(".gallery li a[href^='url']").addClass("tooltip"); or
jQuery(".gallery li a").each(function() {
jQuery(this).attr("href").addClass("tooltip"); });
and many other tricks doesn't work. I need help to achieve this, thanks
--
View this message in context: http://www.nabble.com/addClass-on-ahref-link-on-the-fly-tp22946637s27240p22946637.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.