简体   繁体   English

如何在点击后将按钮文本从show更改为隐藏,并在滑动后保持显示?

[英]How to change the button text from show to hide after click, and also keep it showen after slide up?

i'm trying to do something similler to the map you can see at the end of this site, http://www.insegment.com/ 我正在尝试用similler做一些你可以在本网站末尾看到的地图, http://www.insegment.com/

Here's the html 这是html

    <div class="clear">
    <button id=slideToggle>Show full map</button>
<div class="slideTogglebox">            
</div> </div>

Script: 脚本:

$("#slideToggle").click(function () {   $('.slideTogglebox').slideToggle(500); });

Thank's in advance 提前致谢

Do... 做...

$("#slideToggle").click(function () {   

$(this).html(($(this).html()=="Show full map"?"Hide map":"Show full map"));

// To move up
$(this).toggleClass("moveUp");

$('.slideTogglebox').slideToggle(500); 

});

And put the css to move up in moveUp 然后把css放到moveUp

Here is a jsFiddle , 这是一个jsFiddle

Also.... you're missing a </div> 还....你错过了</div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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