how to add 'show/hide content' option in a webpage in html?
though there are many codes available, bu开发者_StackOverflow社区t i want the simplest and shortest code for an option for show/hide content.( it would be good if the text 'show/hide' can be replaced by an image for the same or by a button)
If you have an element with id="myElem"
, you can do:
elem=document.getElementById("myElem");
elem.style.display = "none";
and to show it:
elem.style.display = "";
If you don't mind a library dependency - jquery can achieved this with
$("#myelm").toggle();
精彩评论