Using jQuery attr('onclick') returns undefined?

Considering that the href from the console message is different from that in your HTML, I'd say that the element at index 0 is different than the one you're targeting.

Considering that the href from the console message is different from that in your HTML, I'd say that the element at index 0 is different than the one you're targeting. If you have multiple instances of . IDX-detailsSubLink a, then you're grabbing the first.

If you have only one on the page, then it returns the function that wraps the content of your inline onclick. If you want the actual attribute, you can use getAttribute() instead. Var $sublinkA = $('.

IDX-detailsSubLink a'); log( $sublinkA0. Href + "\n" + $sublinkA0. GetAttribute('onclick')); But you still need to be referencing the correct element.

If you are just trying to access the value of the onclick attribute, then you can do this: $("elementID"). Attr("onclick"); To fit this in with what you've already got, it would look something like this: var $sublinkA = $('. IDX-detailsSubLink a'); var onclickAttr = $($sublinkA0).

Attr("onclick").

That is what he said isn't working: $("elementID"). Attr("onclick"); – david Jul 1 '11 at 16:56 @david - his code is this: $sublinkA0. Onclick, there is no use of the attr function.

– James Allardice Jul 1 '11 at 16:57 you're right I was looking in the title of his post – david Jul 1 '11 at 16:58 Thank you gentlemen for the help; sorry about the ambiguity - I suppose the title indicated that I had -tried- the .attr() method to no avail. I posted my solution below. Thanks!

– fettereddingoskidney Jul 1 '11 at 17:01 If there's no . Onclick property, then there must not be an onclick attribute either. So .attr() wouldn't give any better result.

– user113716 Jul 1 '11 at 17:05.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions