JavaScript Click button to achieve hidden display switching effect _javascript tips

Source: Internet
Author: User

This article share the click button to realize the hidden and display of the switch code, for your reference, the specific contents are as follows

Effect Chart:

In many applications, there is such a function, click the same button to achieve an element of the display and hidden switch, the following is a code example to introduce how to achieve this effect, the code is as follows:

  
 

The above code to achieve our requirements, click on the top link to achieve a div display and hidden switch, the following describes its implementation process.
Implementation principle:
Registers the OnClick event handler function for a link, This handler can determine the value of the DIV's Style.display property and set it to none for block, which means that the div is set to hidden, otherwise it is set to block, that is, the div is set to display state, which is the principle. What needs special attention is that in Div, the reason why the use of style= "Display:block" is to let Obj.style.display statements can get property values, otherwise the first click can not be set to hide div, we can remove style= " Display:block "Do the test, return false statement is to prevent the link jump effect."

For return FALSE, refer to this article: "return false in learning Jquey"

The above is the entire content of this article, I hope to help you learn.

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.