Solved

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

Posted on 2013-11-20
6
260 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
[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
  • 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 500 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
Industry Leaders: 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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
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…

617 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