Use JS to implement a TreeMenu effect sharing

Source: Internet
Author: User

I want to share some of the things I learned today.
Similar to the TreeMenu control.
Code without nonsense:
Copy codeThe Code is as follows:
<Script language = "javascript">
Function control () {// define a function
If (sMenus3.innerHTML = "+") {// determine the expansion status
UlMenu3.style. display = "block"; // if the number is "+", expand
SMenus3.innerText = "-"; // After expansion, it is displayed as a minus sign.
}
Else {
UlMenu3.style. display = "none"; // if it is a hyphen (-), it cannot be expanded.
SMenus3.innerText = "+"; // The symbol is changed after you click it.
}
}
</Script>

Html code:
// The main difference between this code is that the Id corresponds to the Id in the js Code.
Copy codeThe Code is as follows:
<Body>
<Span id = "sMenus3" style = "border: 1px solid #00000; color: Blue; cursor: hand;" onclick = "control () ">-</span> no website status <br/>
<Ul id = "ulMenu3">
<Li> <a href = "http://www.baidu.com" target = "_ blank"> Baidu </a> </li>
<Li> <a href = "http://www.baidu.com" target = "_ parent"> Baidu </a> </li>
<Li> <a href = "http://www.baidu.com" target = "_ blank"> or Baidu </a> </li>
</Ul>
</Body>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.