js set dataset code example
Example 1: javascript get data-id attribute
var element = document.getElementById('myDivID');
var dataID = element.getAttribute('data-id');
var dataID = $('myDivID').data('data-id');
Example 2: dataset js
for javascript :
webappData.getAttribute('data-id');
document.querySelector('#elementId').dataset.id = 'value';
for jquery :
$(element).attr('data-key', 'value');
Example 3: javascript dataset
<div id="user" data-user-id="2" data-user-date-of-birth="03/03/1993">
<p> Hello ! </p>
</div>
const user = document.getElementById('user')
console.log(user.dataset.userId)
console.log(user.dataset.userDateOfBirth)