jQuery-slideToggle()和切换文本 [英] jQuery - slideToggle() and Toggle Text
问题描述
我有一个可以使用.slideToggle()
隐藏的联系表单,但是我希望用于Toggle
表单的选项卡可以根据表单是in view
还是hidden
来更改文本.
I have a contact form that can be hidden using .slideToggle()
but I want the tab used to Toggle
the form to change text based on wether the form is in view
or hidden
.
这是jQuery:
$("#slider").click(function() {
$("#form_wrap").animate({ opacity: 1.0 },200).slideToggle();
});
我希望#slider
的文本显示为隐藏",然后显示为显示".
I want the text of #slider
to read 'Hide' then 'Show'.
任何帮助表示赞赏!
推荐答案
类似的方法会起作用:
$("#slider").click(function() {
$("#form_wrap").animate({ opacity: 1.0 },200).slideToggle(500, function() {
$("#slider").text($(this).is(':visible') ? "Hide" : "Show");
});
});
我假设您要单击的#slider
标签是您要更改其文字的内容,您的问题使我对该部分感到困惑.动画制作完成后,这将根据最后#form_wrap
的可见性状态来设置按钮的文本.
I assume here the tab you're clicking #slider
is what you want to change the text of, your question confuses me a bit on that part. Once the animation is complete, this sets the text of the button depending on the visibility state of #form_wrap
at the end.
这篇关于jQuery-slideToggle()和切换文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!