The data-*
attributes are used to store custom data. The data-*
attributes generated through jQuery are not visible in the DOM while the data-*
attributes written in the HTML code are visible in the DOM.
My question is what difference is making the jQuery generated element's data-*
attributes not visible in the DOM?
Secondly, can we hide data-*
in the DOM object like in the element generated through jQuery?
$('#div2').append($('<h2/>').html('h2 Element generated with JQUERY').data('test', '5000'));
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="div1">
<h2 data-test="60000">This is h2 Element</h2>
</div>
<div id="div2"></div>