JSFiddle - React, Tailwind, and code Playground

HTML

<script src="http://seankoole.com/json2.js"></script>
<div id="test" data-foo="this is foo"></div>

JavaScript

/*
    jQuery 1.4.2 vs 1.4.3 -- data method reads from the attribute
    * Listens to changes made by attr method

    Default is set to 1.4.3, select 1.4.2 and click run
*/

var div = $('#test');

/*
    1.4.3 = this is foo
    1.4.2 = null
*/
console.log (div.data ('foo'));

/*
    Change the value using .attr
*/
div.attr ('data-foo', 'something else')
    
/*
    1.4.3 = something else
    1.4.2 = null
*/
console.log (div.data ('foo'));