I've been fighting with this simple piece of code forever. I'm trying to use a <button>
to call a simple JavaScript function to hide a <div>
.
HTML:
<button type="button" onclick="close('wrong')">OK</button>
JavaScript:
function close(ID)
{
document.getElementById(ID).style.display="none";
}
I'm sure it's something really simple, I just can't, for the life of me, find it.
Try changing the
close
function name to something else likecloseit
because it may be confusing it with thewindow.close()
function.Let's do something in jQuery:
Now, you need just use the code below to do what you want:
Notice: you can have some properties for hide() function: Fast and slow. This will affect on the speed of hiding action.
I hope this can help you.
Try document.getElementById('wrong').setAttribute('style', 'display:none');