so in my HTML i got this:
<li data-target="#multi-item-example" data-slide-to="2" class="m-0 mr-2 active"></li>
my JS makes this:
var x = document.getElementsByClassName("m-0 mr-2 active");
var y= x.getAttribute("data-slide-to");
alert(y);
but I get:
Uncaught TypeError: x.getAttribute is not a function
want to get the value of data-slide-to with as little code as possible.
This works but is way too long:
var nodes=[], values=[];
for (var att, i = 0, atts = x.attributes, n = atts.length; i < n; i++){
att = atts[i];
nodes.push(att.nodeName);
values.push(att.nodeValue);
}