Click here to Skip to main content
15,169,285 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
can someone gives me an exaple!
Posted
Comments
ZurdoDev 8-Sep-15 14:55pm
   
$("#test").attr("test", "test");

What exactly is your question?
May Bash 8-Sep-15 16:31pm
   
when i say data-attrepute what does that mean for example :
"<tr data-0='index'>
<td> Ray </td>
<td>Villalobos </td>
<td><button type=\"button\" class=\"btn btn-info viewuser\">View User </button></td>
</tr>"
what does it mean to say :
data-0
where can i use it nd why ?

1 solution

html objects can have any attribute you want.

HTML
<a id="myLink" href="somePage.aspx" myattribute="test"></a>


In jQuery you can set that attribute by
JavaScript
$("#myLink").attr("myAttribute", "NewValue");

and can get the attribute with
JavaScript
var attr = $("#myLink").attr("myAttriubte");
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900