How can I get the value of a custom attribute using javascript or jquery?
Like
<strong id="the id" original-title="I NEED THIS">
I've tried with .getAttribute() and attr()
..(Javascrupt & jQuery) without success any idea?
Right-click on a user, then click Properties. Click the Attribute Editor tab, then confirm that the custom attribute you created is listed in the "Attribute" column (e.g., LastPassK1).
A custom attribute is a property that you can define to describe assets. Custom attributes extend the meaning of an asset beyond what you can define with the standard attributes. You can create a custom attribute and assign to it a value that is an integer, a range of integers, or a string.
You can add attributes using attr like so: $('#someid'). attr('name', 'value'); However, for DOM properties like checked , disabled and readonly , the proper way to do this (as of JQuery 1.6) is to use prop .
Don't use space in id.
And adding custom attributes make your html invalid. Use data-attributes
instead:
<strong id="the_id" data-original-title="I NEED THIS"> $('#the_id').data('original-title');
http://jsbin.com/akoyut/2/edit
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With