html - Hide selected element or DIV when clicked -


i looking simplest solution , can't seem right!

i have tried number of combinations , nothing seems work right, here have far:

<div id="hideme" onclick="hideme();">hide div</div>  <script> function hideme(this) { this.parentnode.parentnode.style.display = 'none'; } </script> 

i want in way different div id's can hidden easily

you missed passing in context hideme:

<div id="hideme" onclick="hideme(this);">hide div</div> 

then reference element directly , set display none

function hideme(ele) {     ele.style.display = 'none'; } 

demo - jsbin


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -