How to Get Attribute Value in JQuery?

By Hardik Savani April 6, 2023 Category : jQuery

If you are new and you want to get attribute value then you can get easily. sometime maybe we also need to get custom attribute value, i mean data attribute value. In following example i give you three way to get 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");





I hope it can help you...

Tags :