jquery Instance Tutorial: Making a collapsible panel in a Web page

Source: Internet
Author: User

Let's combine the techniques of a few examples before making a collapsible panel. To achieve the effect below, you need to invoke the Slidedown () method and the Slideup () two methods.

The core jquery code that implements the example:

$ (document). Ready (function () {

$ (". Message_list. MESSAGE_BODY:GT (0)"). Hide ();

$ (". Message_list li:gt (4)"). Hide ();

$ (". Message_head"). Click (function () {

$ (this). Next (". Message_body"). Slidetoggle (500)

return false;


$ (". Collpase_all_message"). Click (function () {

$ (". Message_body"). Slideup (500)

return false;


$ (". Show_all_message"). Click (function () {

$ (this). Hide ()

$ (". Show_recent_only"). Show ()

$ (". Message_list li:gt (4)"). Slidedown ()

return false;


$ (". Show_recent_only"). Click (function () {

$ (this). Hide ()

$ (". Show_all_message"). Show ()

$ (". Message_list li:gt (4)"). Slideup ()

return false;



Line 1th: Hides all elements in the <div class= "Message_body" >, except the first

Line 2nd: Hide all <li> elements after fifth

Part 3rd: When the user clicks <p class= "Message_head" >, the next <div class= "Message_body" > to the Drop-down display operation.

Part 4: <a class= "Collpase_all_message" > Click Yes to fold all <div class= "Message_body" > elements.

Part 5th: When <a class= "Show_all_message", displays <a class= "Show_recent_only", and displays all elements following the fifth <li> element.

Part 6th: When clicked <a class= "Show_recent_only", hides the element, then displays <a class= "Show_all_message", and the 5th <li> after all < Li> elements are folded and hidden.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.