JSFiddle - React, Tailwind, and code Playground

HTML

<div id="test" data-id="123">123</div>
<div id="feedback"></div>

JavaScript

$("#test").on('datachange', function(e, key){
    $('#feedback').text('data "' + key + '" was changed to ' + $(this).data(key));
});

$.fn.mydata=function(key, variable){
    $(this).data(key, variable).trigger('datachange', key);
}

$("#test").mydata('id', 456);