开发者

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();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜