JavaScript自动隐藏和显示HTML标记(DIV,P,随便什么)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JavaScript自动隐藏和显示HTML标记(DIV,P,随便什么)相关的知识,希望对你有一定的参考价值。

  1. <a href="javascript:viewMore('two');" id="xtwo">... more</a>
  2. <p>I see one.</p>
  3. <p id="two" style="display:none">I see two.</p>
  4.  
  5.  
  6. function viewMore(div) {
  7. obj = document.getElementById(div);
  8. col = document.getElementById("x" + div);
  9.  
  10. if (obj.style.display == "none") {
  11. obj.style.display = "block";
  12. col.innerhtml = "... less";
  13. } else {
  14. obj.style.display = "none";
  15. col.innerHTML = "... more";
  16. }
  17. }

以上是关于JavaScript自动隐藏和显示HTML标记(DIV,P,随便什么)的主要内容,如果未能解决你的问题,请参考以下文章