Javascript jQuery最新库不工作脚本
我找到了这个(更多/更少的文本)。当我实现用jquerylib1.11编写代码时,他不工作。我不知道为什么 代码:Javascript jQuery最新库不工作脚本,javascript,jquery,Javascript,Jquery,我找到了这个(更多/更少的文本)。当我实现用jquerylib1.11编写代码时,他不工作。我不知道为什么 代码: <span class="teaser">text goes here</span> <span class="complete"> this is the complete text being shown</span> <span class="more">more...</span> 你能寻求帮助吗?T
<span class="teaser">text goes here</span>
<span class="complete"> this is the complete text being shown</span>
<span class="more">more...</span>
你能寻求帮助吗?Thank用于要显示和隐藏的元素,而不是作为发生的事件。您可能想绑定到更多的:
$(".more").click(function(){
if ($(this).siblings(".complete").is(":visible"))
$(this).text("more..").siblings(".complete").hide();
else
$(this).text("less..").siblings(".complete").show();
});
在jQuery1.8中不推荐使用,在1.9中删除了
浏览器的JavaScript控制台中是否存在任何错误?“不起作用”具体是什么意思?哦,在jQuery1.9中被删除了;所以应该有错误。请参阅以获取不推荐的toggle
方法的实现。请注意,您的fiddle在引用jQuery 1.5.2时起作用。
$(".more").click(function(){
if ($(this).siblings(".complete").is(":visible"))
$(this).text("more..").siblings(".complete").hide();
else
$(this).text("less..").siblings(".complete").show();
});