JSFiddle - React, Tailwind, and code Playground
HTML
<div class="myDiv" data-foo="bar"></div>
JavaScript
$(function(){
var $myDiv = $(".myDiv");
//Display value before changing the data
alert($myDiv.data("foo")); //Displays "bar"
//Change the data value
$myDiv.data("foo", "baz");
//Display the value after changing the data
alert($myDiv.data("foo")) //Displays "baz"
//Display the value of the elements "data-foo" attribute
alert($myDiv.attr("data-foo")); //Displays "bar"
});