I have a input that I press then this event is called:
document.getElementById("nearest").addEventListener('click', function(){
x$("#popup").toggleClass('hide');
}, false);
then I get this error in console:
x$("#popup").toggleClass is not a function
[Break On This Error] x$("#popup").toggleClass('hide');
This is the div and the input element
<div id="popup" class="hide"></div>
<input id="nearest" type="image" name="nearest">
The below code seems to work as expected—it toggles the background color from red to blue (tested in FireFox 8.0 and Chrome 17.0.942.0):
Just to confirm, I assume the
document.getElementId()
you originally used was part of a function or enclosed in some onLoad script? In the working example I used XUIsready()
function to make sure the DOM had loaded.It's also worth noting that the below code is equivalent, since you're using XUI anyway: