javascript get data-id attribute

JavaScript
const dataId = $('#elementId').attr("data-id");//get data-id attribute in plain Javascript
var element = document.getElementById('myDivID');
var dataID = element.getAttribute('data-id');

//get data-id using jQuery
var dataID = $('myDivID').data('data-id');

Source

Also in JavaScript: