I have one onclick
as below
<div class="tablinks active" onclick="openmarket(event,this)" data-uid="1">
openmarket
function like below
function openmarket(evt, obj) {
var i, tabcontent2, tablinks2;
tabcontent2 = document.getElementsByClassName("tabcontent2");
for (i = 0; i < tabcontent2.length; i++) {
tabcontent2[i].style.display = "none";
}
tablinks2 = document.getElementsByClassName("tablinks2");
for (i = 0; i < tablinks2.length; i++) {
tablinks2[i].className = tablinks2[i].className.replace(" active", "");
}
document.getElementById(obj.getAttribute('data-uid')).style.display = "block";
evt.currentTarget.className += " active";
}
Here in this function I have passed 2 parameters,
1) event
2) object
now I try to click this div by JS like below.
$("div [data-uid='1']").click();
but it won't work because I guess parameter evt
is not valid or mismatch from what it should be.
Can anyone help me ?
Thank you.
Edit I'm getting following error.
Cannot read property 'className' of undefined
and error line is evt.currentTarget.className += " active";