JQuery – how to get attribute value example

JQuery – how to get attribute value example

In this post we will give you information about JQuery – how to get attribute value example. Hear we will give you detail about JQuery – how to get attribute value exampleAnd how to use it also give you demo for it if it is necessary.

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.

Example:

<html lang="en">

<head>

<title>Get Custom Attribute Value</title>

<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>

</head>

<body>

<a href="example.com" data-id="1" myname="hd">Example</a>

<script type="text/javascript">


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

alert(a_href);


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

alert(a_data_id);


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

alert(a_myname);


</script>

</body>

</html>

Hope this code and post will helped you for implement JQuery – how to get attribute value example. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

Your email address will not be published. Required fields are marked *

54  +    =  61

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US