How can I get the value of a custom attribute using JavaScript?
Like
<strong id="the_id" original-title="I NEED THIS">
I've tried .getAttribute() and jQuery’s .attr() without success.
You can do it using plain JavaScript:
document.getElementById("the_id").getAttribute("original-title")
Adding custom attributes makes your HTML invalid. Use custom data attributes instead:
<strong id="the_id" data-original-title="I NEED THIS">
$('#the_id').data('original-title')
data- attribute changed. $('#the_id').attr('data-original-title') gets the current value of the attribute.
data-*attributes. Your current markup is invalid.