0

assume that I have this list:

<ul id="carousel"> 
    <li><a title="hey"><img src="image.png"/></a></li>  
</div>

And now my jQuery script:

$(function() {  
    $("#carousel a").click(function(){
    var url = $(this).attr('title');
    alert(url);

    });
}); 

This doesn't work, it works for other attributes such as "alt", "rel" etc. I will be greatful for any assistance.

3
  • Is that extra quote intentional? Commented Dec 29, 2009 at 22:22
  • 2
    Attributes, not tags. <title> is a tag, and it has a very different meaning to the title attribute. Commented Dec 29, 2009 at 22:23
  • 2
    I hope that the </div> is a </ul> in your real markup. Commented Dec 29, 2009 at 22:25

3 Answers 3

5

Works for me in Safari 4 on Mac OS X. What browser are you using? Does the example I linked to fail for you?

Sign up to request clarification or add additional context in comments.

Comments

0

Your example is perfect (because I did try it and it works) , if you using IE8 try to cleare the cache.

Comments

0

I believe it will not work in Firefox because of your invalid markup (as seen in Brian Campbell's link). IE8 seems to work fine following the same link. It would seem that IE8 does not care about closing the <ul>.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.