jQuery-slideToggle()和切换文本 [英] jQuery - slideToggle() and Toggle Text

查看:76
本文介绍了jQuery-slideToggle()和切换文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个可以使用.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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆