JSFiddle - React, Tailwind, and code Playground

by orchid1

HTML

<span id="mySpan" data-hello="world" data-foo="bar" data-item-id="1234567"></span>

JavaScript

jQuery().ready(function($) {   

//the old school way
console.log(typeof $('#mySpan').attr('data-item-id'));    //will output String
    
//the new way
console.log(typeof $('#mySpan').data('item-id'));   //will output Number

//if we wanted to do math we would need to first parse the value using the first method
console.log(typeof parseInt($('#mySpan').attr('item-id'),10));    //will output Number});
});