Jquery 切换()元';t在提供的文本之间循环
测试网站: 我有一个幻灯片,用户要求是可选的。我有一个按钮,可以隐藏或显示幻灯片。代码如下:Jquery 切换()元';t在提供的文本之间循环,jquery,Jquery,测试网站: 我有一个幻灯片,用户要求是可选的。我有一个按钮,可以隐藏或显示幻灯片。代码如下: //hiding and showing the slideshow $('#show_hide_button').click(function(){ $('.fluid_container').slideToggle(); $('#show_hide_button').toggle( function(){ $('#show_hide_button').text
//hiding and showing the slideshow
$('#show_hide_button').click(function(){
$('.fluid_container').slideToggle();
$('#show_hide_button').toggle(
function(){
$('#show_hide_button').text("Show the slideshow");
},
function(){
$('#show_hide_button').text("Hide the slideshow");
});
});
(文件)。准备就绪已实施
幻灯片将成功隐藏和显示问题:文本更改为“显示幻灯片”并保持该状态。开关似乎不能正常工作。你能在我的编码中找到错误吗?我建议:
//hiding and showing the slideshow
$('#show_hide_button').click(function(){
$('.fluid_container').slideToggle();
//this will set the text to whichever it is not already
$('#show_hide_button').text(function (index, text) {
return (text == "Show the slideshow" ? "Hide the slideshow" : "Show the slideshow");
});
});
$('#show_hide_button').click(function(){
$this = $(this);
$('.fluid_container').slideToggle();
if($this.hasClass('showed')){
$('#show_hide_button').text('Hide..');
$this.removeClass('showed');
}
else {
$('#show_hide_button').text('show..');
$this.addClass('showed');
}
});
我建议:
$('#show_hide_button').click(function(){
$this = $(this);
$('.fluid_container').slideToggle();
if($this.hasClass('showed')){
$('#show_hide_button').text('Hide..');
$this.removeClass('showed');
}
else {
$('#show_hide_button').text('show..');
$this.addClass('showed');
}
});
什么版本的jQuery?1.8.3是我当前的版本什么版本的jQuery?1.8.3是我当前的版本太多了!如果我有钱,知道你去哪家酒吧,而且年纪大了,我会给你买杯啤酒。但是我想知道一些简单的事情,当你调用一次性函数时,你需要两个变量,索引和测试。函数从何处获取这些变量及其值?它们内置于jquery.text()函数中,是元素在集合中的索引位置,以及当前的文本值:,感谢您的支持!非常感谢!如果我有钱,知道你去哪家酒吧,而且年纪大了,我会给你买杯啤酒。但是我想知道一些简单的事情,当你调用一次性函数时,你需要两个变量,索引和测试。函数从何处获取这些变量及其值?它们内置于jquery.text()函数中,是元素在集合中的索引位置,以及当前的文本值:,感谢您的支持!我认为@mr_lewjam更流畅,因为它的代码更少,进程也更少。虽然这确实有效,但我同意。谢谢你!不客气。我发布这个解决方案是因为我认为整个字符串上的语句可能会带来问题,但也是一个很好的解决方案!再见!我认为@mr_lewjam更流畅,因为它的代码更少,进程也更少。虽然这确实有效,但我同意。谢谢你!不客气。我发布这个解决方案是因为我认为整个字符串上的语句可能会带来问题,但也是一个很好的解决方案!再见!