Get value of a Custom Attribute using Javascript or Jquery

Solution 1:

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

Solution 2:

Change "the id" to "the_id".

You can do it using plain javascript:

document.getElementById("the_id").getAttribute("original-title");

Solution 3:

Best Way to use like this:

jQuery(this).attr('original-title');

Solution 4:

You can get the value by using the following syntax

$('#theid').attr('original-title');

Solution 5:

a var DateofEvent = $('[data-original-title=I NEED THIS]').val();