Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How do you make a collapsible div with "+" "-" that toggle

Posted on 2013-11-20
6
Medium Priority
?
262 Views
Last Modified: 2013-11-21
Hi,

I have a collapsible div with some content that I need to have a "+" "-" next to the header "airplanes" that toggle as well.

Here is what I have so far

  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
  
	    <script type="text/javascript">
	        $(function() {
	         $('#toggleair').click(function() {
	    $('.toggleair').toggle();
	    return false;
	});
        });
    </script>



<a href="#" id="toggleair">Airplanes</a><br /><br />
<div class="toggleair">
Cessna<br />
Piper<br />
Douglas</div>

Open in new window

0
Comment
Question by:smfmetro10
  • 3
  • 3
6 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 39664591
http://jsfiddle.net/GaryC123/LWXdr/1/

CSS
#toggleair:after {
    content:" -";
}
.toggleair_expand:after {
    content:" +" !important;
}

Open in new window


jQuery
$(function() {
	$('#toggleair').click(function() {
$('#toggleair').toggleClass("toggleair_expand");
	    $('.toggleair').toggle();
	    return false;
	});
        });

Open in new window

0
 

Author Comment

by:smfmetro10
ID: 39666288
Thanks for the reply!

Is there a way for the "+" "-" to be on the other side of the "airplanes" and also to not have the underline (just have the underline under "airplanes")?

Thanks!
0
 
LVL 58

Accepted Solution

by:
Gary earned 2000 total points
ID: 39666369
This is based on this exact layout, it may need to be changed if you start changing the layout of your code
http://jsfiddle.net/GaryC123/LWXdr/3/
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:smfmetro10
ID: 39666371
and or be able to move the "+" "-" a couple spaces away from the  "airplanes" text?
0
 
LVL 58

Expert Comment

by:Gary
ID: 39666383
Did you miss my comment ^^^
0
 

Author Closing Comment

by:smfmetro10
ID: 39666465
Perfect! Thanks!
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…
Suggested Courses

916 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