Hello,
Lately that I’ve been working a lot with jQuery, I have noticed how easy and small functions get endless possibilities for improving code. In this article, you will learn how to get the value of any attribute of an element with jQuery using attr()
We will imagine we have the following HTML code:
<a class='ourlink' href='#' besthosting='Arvixe'>The Best Hosting</a>
You can notice that we have an attribute called besthosting with Arvixe as its value. To get that value with jQuery, we would run the following code.
var attribute = $('.ourlink').attr('besthosting');alert(attribute); //This would alert "Arvixe"
That’s it! If you have any questions, comments, or suggestions, please do not hesitate to contact me and I’ll be more than glad to assist you.
Best Regards,
Richi
Owner of Juapo2Services
Looking for quality web hosting? Look no further than Arvixe Web Hosting!