Get the value of an attribute


The .attr() method gets the attribute value for only the first element in the matched set.

Hello World


​var link = $('a').attr('href');​​​​​​​​
alert(link);


With the above example you will get the href of the anchor tag.

Advertisements

7 thoughts on “Get the value of an attribute

  1. I would like to thnkx for the efforts you have put in writing this web site. I am hoping the same high-grade site post from you in the upcoming also. Actually your creative writing abilities has encouraged me to get my own site now. Really the blogging is spreading its wings fast. Your write up is a good example of it.

  2. You really make it seem really easy with your presentation however I to find this topic to be really one thing that I think I’d by no means understand. It kind of feels too complicated and extremely wide for me. I’m looking forward in your next put up, I’ll try to get the hold of it!

  3. I’ve been absent for some time, but now I remember why I used to love this website. Thank you, I’ll try and check back more often. How frequently you update your site?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s