I have a webpage which has multiple links. What I want to do is I want to open all the links in different windows using javascript. As of now, my code looks like below. All the links have common calss "myClass" and different "id".
$( document ).ready(function() {
var elements = document.getElementsByClassName("myClass");
for (var i = 0; i < elements.length; i++) {
alert(elements[i].getAttribute("id"));
$(elements[i].getAttribute("id")).onclick();
}})
What am I doing wrong? Could anyone help me on this. Any help would be much appreciated.