August 9th, 2017, 01:30 PM
-
GetElementById( i need 3 IDs here)
Hello guys.
I need to use three IDs
i tried this but its not working
Code:
document.querySelectorAll("#panel, #login, #showReg").onclick
August 9th, 2017, 02:37 PM
-
querySelectorAll returns an array of elements. You'd have to loop over the array and assign the onclick to each individual element. Or just call getElementById three times.
Code:
function yourClickHandler(){
//...
}
document.getElementById('panel').onclick = yourClickHandler;
document.getElementById('login').onclick = yourClickHandler;
document.getElementById('showReg').onclick = yourClickHandler;
Or use jQuery to make things easier.
Code:
JQuery('#panel, #login, #showReg').click(function(){
//...
});
If I helped you out, show some love with some reputation, or tip with Bitcoins to 1N645HfYf63UbcvxajLKiSKpYHAq2Zxud