?
Solved

How do you make a collapsible div with "more" "less" that toggle

Posted on 2013-11-08
2
Medium Priority
?
471 Views
Last Modified: 2013-11-08
Hi,

I am looking for a way to loop through a recordset and if It has more than one record append a  "more" "less" with a collapsible div that holds the extra info.

I can "hard code" it but I need a way to have it be dynamic... I'm guess its using the .next method.

Thanks!
0
Comment
Question by:smfmetro10
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 2000 total points
ID: 39634678
Something like this
http://jsfiddle.net/GaryC123/Ua9q9/1/

<div class="parent more">Header
    <div>sub text</div>
</div>

Open in new window

.parent div {
    display:none
}
.showmore:after {
    content:"+"
}
.showless:after {
    content:"-"
}

Open in new window

$(".more").each(function(){
    $(this).addClass("showmore")
})
$(".more").click(function(){
    if($(this).hasClass("showless")){
        $(this).removeClass("showless").addClass("showmore")}
    else{
        $(this).addClass("showless").removeClass("showmore")
    }
  $("div",this).slideToggle()
})

Open in new window

0
 

Author Closing Comment

by:smfmetro10
ID: 39634935
Yep! Thanks!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question