how to extract java script elemet 1

how to extract java script elemet

var MyDiv1 = document.getElementById('myid');
alert(MyDiv1.getAttribute('data-variableid2'));

Here is what the above code is Doing:
1. It’s creating a div element with an id of “myid” and a data-variableid2 attribute with a value of “myvalue”.
2. It’s then getting the div element by its id and alerting the value of the data-variableid2 attribute.

Similar Posts