简体   繁体   中英

How to call two ID's alternatively with one button?

Take a look at example.

<button id="go">Expand</button>
<button id="go1">Collapse</button>

I want if someone press Expand then expand function should work and automatically hide expand button and show Collapse button and when Collapse button is pressed then it should hide and Expand appear.

Thanks in Advance For All My Brothers For Giving Solution.

not exactly the copy to use answer but you can modify it to achieve your target

the html

 <p id="disclaimer">
    Disclaimer! This service is not intended for the those with criminal intent. Celebrities are kind of like people so their privacy should be respected.
  </p>
  <input type="button" id="toggleButton" value="toggle" />

the jquery

$(document).ready(function(){
$('#toggleButton').click(function(){
if($('#disclaimer').is(':visible')) {
  $('#disclaimer').hide();
} else {
  $('#disclaimer').show();
}
});
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM