How to get attribute value in JQuery

Today now in this post i will show you How to get attribute value in JQuery. If you are new and if you want to get the attribute value then i hope you can get this easily. Sometime maybe you also need to get the custom attribute value, here i mean that data attribute value. So now in the following example i will give you three way to get the custom attribute value in jquery.


<html lang="en">
	<title>Get Custom Attribute Value</title>
	<script src=""></script>
	<a href="" data-id="1" myname="hd">Example</a>
    <script type="text/javascript">

	    var a_href = $("a").attr("href");

	    var a_data_id = $("a").data("id");

	    var a_myname = $("a").attr("myname");


Read Also : How to convert Object into Array in PHP?

Thanks for read. I hope it help you. For more you can follow us on facebook.


About Shahriar Sagor

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by Shahriar Sagor →