How to Get Attribute Value in 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.
<title>Get Custom Attribute Value</title>
<a href="example.com" data-id="1" myname="hd">Example</a>
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...
We are Recommending you
- How to Remove Special Characters from a String in JQuery?
- JQuery Remove All Numbers from String Example
- How to Download File using JQuery?
- How to use Laravel Variable in JQuery?
- Jquery Convert Object to String Example
- Jquery - How to Count Child Elements in Div?
- Jquery Remove Parent Table Row on Button Click Event
- How to check if key exists in json object in jquery?
- How to remove comma from string in jquery with example ?
- Jquery - draggable sortable table rows example demo with bootstrap
- How to Upload Image using jQuery Ajax in PHP?
- How to Allow Only One Checkbox Checked at a Time in JQuery?
- How to Check Undefined, Empty and Null in JQuery?
- How to Convert Line Breaks to br in jQuery ?