Question

Jquery:hide/show text (show/hide div)

Asked by: AndyPSV

Hello, I've got script like below and want to 'force' text: 'expand all' to make 'collapse all' after taking  an action. I would like to notice also that they're 2 links to the javascript code (<h1> and "Collapse All" link)

How to do to 'after' action change text from: expand all on collapse all and reverse?

<div class='tp box shadow radius clearfix' id='w4'>
	<div class='fl'><h1 class='btm2 up pointer'>search catalogs: basics</h1></div>
	<div class='fr'><h1 class='btm2'><a href='#'>Collapse All</a></h1></div>
	<div class='fix'></div>
	
	<form action='<% $URL %>c' method='post'>
	<div id='s'><br />
		<input type='hidden' name='<% $HIDE %>' value='k' />
		<div class='fl sp1'>&nbsp;</div><div class='fl'><dl><dt><label for='nick'>Nickname, Nick</label></dt><dd><input type='text' name='nick' id='nick' size='25' value='AndyPSV' title='Your nickname would be public' />&nbsp;&nbsp;&nbsp;&nbsp;</dd><dt><label for='first_name'>First Name</label></dt><dd><input type='text' name='first_name' id='first_name' size='15' value='Andrzej22' title='Please enter your first name' />&nbsp;<input type='text' name='last_name' id='last_name' size='25' value='dsdsasda' title='Please enter your last name' /> <img src='http://localhost/tpl/i/img/ico/mini-lock.gif' alt='' /></dd><dt><label for='birth'>Date of Birth</label></dt><dd><select name='dd' id='dd'><option value=''>DAY:</option><option value='01'>01</option><option value='02' selected='selected'>02</option><option value='03'>03</option><option value='04'>04</option><option value='05'>05</option><option value='06'>06</option><option value='07'>07</option><option value='08'>08</option><option value='09'>09</option><option value='10'>10</option><option value='11'>11</option><option value='12'>12</option><option value='13'>13</option><option value='14'>14</option><option value='15'>15</option><option value='16'>16</option><option value='17'>17</option><option value='18'>18</option><option value='19'>19</option><option value='20'>20</option><option value='21'>21</option><option value='22'>22</option><option value='23'>23</option><option value='24'>24</option><option value='25'>25</option><option value='26'>26</option><option value='27'>27</option><option value='28'>28</option><option value='29'>29</option><option value='30'>30</option><option value='31'>31</option></select><select name='mm' id='mm'><option value=''>MONTH:</option><option value='01' selected='selected'>January</option><option value='02'>February</option><option value='03'>March</option><option value='04'>April</option><option value='05'>May</option><option value='06'>June</option><option value='07'>July</option><option value='08'>August</option><option value='09'>>September</option><option value='10'>October</option><option value='11'>November</option><option value='12'>December</option></select><select name='yyyy' id='yyyy'><option value=''>YEAR:</option><option value='1940'>1940</option><option value='1941'>1941</option><option value='1942'>1942</option><option value='1943'>1943</option><option value='1944'>1944</option><option value='1945'>1945</option><option value='1946'>1946</option><option value='1947'>1947</option><option value='1948' selected='selected'>1948</option><option value='1949'>1949</option><option value='1950'>1950</option><option value='1951'>1951</option><option value='1952'>1952</option><option value='1953'>1953</option><option value='1954'>1954</option><option value='1955'>1955</option><option value='1956'>1956</option><option value='1957'>1957</option><option value='1958'>1958</option><option value='1959'>1959</option><option value='1960'>1960</option><option value='1961'>1961</option><option value='1962'>1962</option><option value='1963'>1963</option><option value='1964'>1964</option><option value='1965'>1965</option><option value='1966'>1966</option><option value='1967'>1967</option><option value='1968'>1968</option><option value='1969'>1969</option><option value='1970'>1970</option><option value='1971'>1971</option><option value='1972'>1972</option><option value='1973'>1973</option><option value='1974'>1974</option><option value='1975'>1975</option><option value='1976'>1976</option><option value='1977'>1977</option><option value='1978'>1978</option><option value='1979'>1979</option><option value='1980'>1980</option><option value='1981'>1981</option><option value='1982'>1982</option><option value='1983'>1983</option><option value='1984'>1984</option><option value='1985'>1985</option><option value='1986'>1986</option><option value='1987'>1987</option><option value='1988'>1988</option><option value='1989'>1989</option><option value='1990'>1990</option><option value='1991'>1991</option><option value='1992'>1992</option><option value='1993'>1993</option><option value='1994'>1994</option><option value='1995'>1995</option><option value='1996'>1996</option><option value='1997'>1997</option><option value='1998'>1998</option><option value='1999'>1999</option><option value='2000'>2000</option><option value='2001'>2001</option><option value='2002'>2002</option><option value='2003'>2003</option><option value='2004'>2004</option><option value='2005'>2005</option><option value='2006'>2006</option></select>										</dd><dt><label for='country'>Country</label></dt><dd><select name='country' id='country'><option value=''>&ndash; select country &ndash;</option><option value='1'>United States</option><option value='2'>United Kingdom</option><option value='3'>Norway</option><option value='4'>Greece</option><option value='5'>Afghanistan</option><option value='6' selected='selected'>Albania</option><option value='7'>Algeria</option><option value='8'>American Samoa</option><option value='9'>Andorra</option><option value='10'>Angola</option><option value='11'>Anguilla</option><option value='12'>Antigua &amp; Barbuda</option><option value='13'>Antilles, Netherlands</option><option value='182'>Senegal</option><option value='15'>Argentina</option><option value='16'>Armenia</option><option value='17'>Aruba</option><option value='18'>Australia</option><option value='19'>Austria</option><option value='20'>Azerbaijan</option><option value='21'>Bahamas, The</option><option value='22'>Bahrain</option><option value='23'>Bangladesh</option><option value='24'>Barbados</option><option value='25'>Belarus</option><option value='26'>Belgium</option><option value='27'>Belize</option><option value='28'>Benin</option><option value='29'>Bermuda</option><option value='30'>Bhutan</option><option value='31'>Bolivia</option><option value='32'>Bosnia and Herzegovina</option><option value='33'>Botswana</option><option value='34'>Brazil</option><option value='35'>British Virgin Islands</option><option value='36'>Brunei Darussalam</option><option value='37'>Bulgaria</option><option value='38'>Burkina Faso</option><option value='39'>Burundi</option><option value='40'>Cambodia</option><option value='41'>Cameroon</option><option value='42'>Canada</option><option value='43'>Cape Verde</option><option value='44'>Cayman Islands</option><option value='45'>Central African Republic</option><option value='46'>Chad</option><option value='47'>Chile</option><option value='48'>China</option><option value='49'>Colombia</option><option value='50'>Comoros</option><option value='51'>Congo</option><option value='52'>Congo</option><option value='53'>Cook Islands</option><option value='54'>Costa Rica</option><option value='55'>Cote D'Ivoire</option><option value='56'>Croatia</option><option value='57'>Cuba</option><option value='58'>Cyprus</option><option value='59'>Czech Republic</option><option value='60'>Denmark</option><option value='61'>Djibouti</option><option value='62'>Dominica</option><option value='63'>Dominican Republic</option><option value='64'>East Timor (Timor-Leste)</option><option value='65'>Ecuador</option><option value='66'>Egypt</option><option value='67'>El Salvador</option><option value='68'>Equatorial Guinea</option><option value='69'>Eritrea</option><option value='70'>Estonia</option><option value='71'>Ethiopia</option><option value='72'>Falkland Islands</option><option value='73'>Faroe Islands</option><option value='74'>Fiji</option><option value='75'>Finland</option><option value='76'>France</option><option value='77'>French Guiana</option><option value='78'>French Polynesia</option><option value='79'>Gabon</option><option value='80'>Gambia, the</option><option value='81'>Georgia</option><option value='82'>Germany</option><option value='83'>Ghana</option><option value='84'>Gibraltar</option><option value='86'>Greenland</option><option value='87'>Grenada</option><option value='88'>Guadeloupe</option><option value='89'>Guam</option><option value='90'>Guatemala</option><option value='91'>Guernsey and Alderney</option><option value='92'>Guinea</option><option value='93'>Guinea-Bissau</option><option value='94'>Guinea, Equatorial</option><option value='95'>Guiana, French</option><option value='96'>Guyana</option><option value='97'>Haiti</option><option value='179'>San Marino</option><option value='99'>Honduras</option><option value='100'>Hong Kong, (China)</option><option value='101'>Hungary</option><option value='102'>Iceland</option><option value='103'>India</option><option value='104'>Indonesia</option><option value='105'>Iran, Islamic Republic of</option><option value='106'>Iraq</option><option value='107'>Ireland</option><option value='108'>Israel</option><option value='109'>Ivory Coast (Cote d'Ivoire)</option><option value='110'>Italy</option><option value='111'>Jamaica</option><option value='112'>Japan</option><option value='113'>Jersey</option><option value='114'>Jordan</option><option value='115'>Kazakhstan</option><option value='116'>Kenya</option><option value='117'>Kiribati</option><option value='118'>Korea, (South) Rep. of</option><option value='119'>Kuwait</option><option value='120'>Kyrgyzstan</option><option value='121'>Lao People's Dem. Rep.</option><option value='122'>Latvia</option><option value='123'>Lebanon</option><option value='124'>Lesotho</option><option value='125'>Libyan Arab Jamahiriya</option><option value='126'>Liechtenstein</option><option value='127'>Lithuania</option><option value='128'>Luxembourg</option><option value='129'>Macao, (China)</option><option value='130'>Macedonia, TFYR</option><option value='131'>Madagascar</option><option value='132'>Malawi</option><option value='133'>Malaysia</option><option value='134'>Maldives</option><option value='135'>Mali</option><option value='136'>Malta</option><option value='137'>Martinique</option><option value='138'>Mauritania</option><option value='139'>Mauritius</option><option value='140'>Mexico</option><option value='141'>Micronesia</option><option value='142'>Moldova, Republic of</option><option value='143'>Monaco</option><option value='144'>Mongolia</option><option value='145'>Montenegro</option><option value='146'>Morocco</option><option value='147'>Mozambique</option><option value='148'>Myanmar (ex-Burma)</option><option value='149'>Namibia</option><option value='150'>Nepal</option><option value='151'>Netherlands</option><option value='152'>New Caledonia</option><option value='153'>New Zealand</option><option value='154'>Nicaragua</option><option value='155'>Niger</option><option value='156'>Nigeria</option><option value='157'>Northern Mariana Islands</option><option value='159'>Oman</option><option value='160'>Pakistan</option><option value='161'>Palestinian Territory</option><option value='162'>Panama</option><option value='163'>Papua New Guinea</option><option value='164'>Paraguay</option><option value='165'>Peru</option><option value='166'>Philippines</option><option value='167'>Poland</option><option value='168'>Portugal</option><option value='170'>Qatar</option><option value='171'>Reunion</option><option value='172'>Romania</option><option value='173'>Russian Federation</option><option value='174'>Rwanda</option><option value='175'>Saint Kitts and Nevis</option><option value='176'>Saint Lucia</option><option value='177'>St. Vincent &amp; the Grenad.</option><option value='178'>Samoa</option><option value='180'>Sao Tome and Principe</option><option value='181'>Saudi Arabia</option><option value='183'>Serbia</option><option value='184'>Seychelles</option><option value='185'>Singapore</option><option value='186'>Slovakia</option><option value='187'>Slovenia</option><option value='188'>Solomon Islands</option><option value='189'>Somalia</option><option value='190'>Spain</option><option value='191'>Sri Lanka (ex-Ceilan)</option><option value='192'>Sudan</option><option value='193'>Suriname</option><option value='194'>Swaziland</option><option value='195'>Sweden</option><option value='196'>Switzerland</option><option value='197'>Syrian Arab Republic</option><option value='198'>Taiwan</option><option value='199'>Tajikistan</option><option value='200'>Tanzania, United Rep. of</option><option value='201'>Thailand</option><option value='202'>Togo</option><option value='203'>Tonga</option><option value='204'>Trinidad &amp; Tobago</option><option value='205'>Tunisia</option><option value='206'>Turkey</option><option value='207'>Turkmenistan</option><option value='208'>Uganda</option><option value='209'>Ukraine</option><option value='210'>United Arab Emirates</option><option value='211'>Uruguay</option><option value='212'>Uzbekistan</option><option value='213'>Vanuatu</option><option value='214'>Venezuela</option><option value='215'>Viet Nam</option><option value='216'>Virgin Islands, U.S.</option><option value='217'>Yemen</option><option value='218'>Zambia</option><option value='219'>Zimbabwe</option></select>										</dd><dt><label for='postcode'>Postcode</label></dt><dd><input type='text' name='postcode' id='postcode' size='15' value='dsasda' title='Please enter your postcode' />&nbsp;&nbsp;&nbsp;&nbsp;</dd><dt><label for='city'>City</label></dt><dd><input type='text' name='city' id='city' size='25' value='ddd' title='Please enter your city' />&nbsp;&nbsp;&nbsp;&nbsp;</dd></dl></div>
		<div class='fl sp1'>&nbsp;</div>
		<div class='fl'>
			<p class='b btm2'><img src='<% $TPL %>img/ico/icon-right.gif' alt='' /> Community</p>
			<p class='b btm2'><img src='<% $TPL %>img/ico/icon-right.gif' alt='' /> Personal</p>
			<p class='b btm2'><img src='<% $TPL %>img/ico/icon-right.gif' alt='' /> Personality</p>
			<p class='b btm2'><img src='<% $TPL %>img/ico/icon-right.gif' alt='' /> Physical</p>
			<p class='b btm3'><img src='<% $TPL %>img/ico/icon-right.gif' alt='' /> Groups</p>
			<p class='al'><% include file = $TPLx.'m/s/btn.html' %></p>
			
		<!--<dl><dt><label for='phone'><label for='phone_cc'>Phone Number</label></label></dt><dd>+ <input type='text' name='phone_cc' size='1' maxlength='4' value='22' id='phone_cc' title='Please enter your Country Code' />&nbsp;&ndash;&nbsp; <input type='text' name='phone_ac' size='1' maxlength='3' value='22' id='phone_ac' title='Please enter your Area Code' />&nbsp;&ndash;&nbsp; <input type='text' name='phone_pn' size='8' maxlength='8' value='2223' id='phone_pn' title='Please enter your Phone Number' /><br /><span class='dsc pdng'>e.g. 86&nbsp;&ndash;&nbsp;&nbsp;&nbsp;&nbsp;571&nbsp;&nbsp;&ndash;&nbsp;&nbsp;&nbsp;12345678</span>										</dd><dt><label for='skype'>Skype</label></dt><dd><input type='text' name='skype' id='skype' size='25' value='2121' />&nbsp;&nbsp;&nbsp;&nbsp;</dd><dt><label for='yahoo'>Yahoo</label></dt><dd><input type='text' name='yahoo' id='yahoo' size='25' value='dddd' />&nbsp;&nbsp;&nbsp;&nbsp;</dd><dt><label for='msn'>MSN</label></dt><dd><input type='text' name='msn' id='msn' size='25' value='q2112' />&nbsp;&nbsp;&nbsp;&nbsp;</dd><dt><label for='www'>WWW</label></dt><dd>http://&nbsp;<input type='text' name='www' id='www' size='25' value='rcdrugs.com' />&nbsp;&nbsp;&nbsp;&nbsp;</dd><dt>&nbsp;</dt><dd>&nbsp;</dt><dt>&nbsp;</dt><dd class='fr'><button type='submit' class='fg-button button-small ui-state-default fg-button-icon-right ui-corner-all up'><span class='ui-icon ui-icon-circle-arrow-e'></span>save&nbsp;&nbsp;&nbsp;</button></dd>			</dl>-->
		</div><div class='fix'></div>
	</div>	
</div>
<div class='fix'>&nbsp;</div>
 
<script type='text/javascript'>$(document).ready(function(){$('h1.btm2').click(function(){$('#s').toggle('slow')})});</script>

                                  
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:

Select allOpen in new window

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-07-07 at 01:11:45ID24548814
Tags

jquery

,

hide

,

show

Topics

Jquery

,

JavaScript

,

Asynchronous Javascript and XML (AJAX)

Participating Experts
1
Points
500
Comments
2

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. jQuery expand/collapse
    i have a code snippet i picked up from somewhere (i can't remember where now) but i'd like to add a simple fading effect to it. this snippet uses jQuery's slideToggle function to simply expand & contract a div. I'd like to also add jQuery's fading function to this, but i ...
  2. jQuery: append h1 items in random order
    I use the following code to append h1 items to a div. How can I append them in random order?
  3. Jquery Expand / Collapse Div Based on Height
    I'm using the following jquery code to expand a div. I'm new to jquery, and have been trying to collapse the div after it is open. Ultimately I would like to change the expand / collapse text on the button (from expand to collapse depending on the state of the div) I'm sure ...
  4. div expand with jquery
    Hi, I'm kind of stuck with jquery for the moment. I'm trying to get my div to expand when some I click on a blockdiv...which works, but! When I click it it expands but jumps after a while, so it loses it smoothness :) Also what I would like is the div to hover above the we...
  5. jquery expanding div problem
    I have an expending div, using jQuery. When you hover over the div (which holds an image) it expands to show some instructional text. The problem is, that if you exit by moving your mouse down over the newly exposed text and out of the expanded area, it doesn't collapse. If ...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: JohnSixkillerPosted on 2009-07-07 at 01:29:47ID: 24792341

Hi,

you mean something like this?

...
<div class='fr'><h1 class='btm2'><a href='#' id='hText'>Collapse All</a></h1></div>
...
...
<script type='text/javascript'>$(document).ready(function(){$('h1.btm2').click(function(){$('#s').toggle('slow',function(){$("#hText").html($("#s").css('display') == 'none' ? "Expand All" : "Collapse All");  })})});</script>

                                              
1:
2:
3:
4:
5:

Select allOpen in new window

 

by: AndyPSVPosted on 2009-07-07 at 01:32:06ID: 31600506

thanks

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...