JSFiddle - React, Tailwind, and code Playground
HTML
<div id="showValue" class="button">(Click) Show data-demo attribute</div>
<div class="update button">(Click) Update text and data-demo attribute</div>
<br>
<div class="value" data-demo="not updated">Not updated</div>
CSS
.button{
display:block;
padding:5px;
margin:5px;
background:#ccc;
color:#fff;
cursor:pointer;
}
JavaScript
$('#showValue').click(function(){
alert($('.value').data('demo'));
});
$('.update').click(function(){
$('.value').text('updated').attr('data-demo', 'updated');
});