Solved

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

Posted on 2009-07-07
2
1,434 Views
Last Modified: 2012-06-22
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>

Open in new window

0
Comment
Question by:AndyPSV
2 Comments
 
LVL 11

Accepted Solution

by:
JohnSixkiller earned 500 total points
ID: 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>

Open in new window

0
 

Author Closing Comment

by:AndyPSV
ID: 31600506
thanks
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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)

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now