我在网站上创建了一个快速选项卡部分。点击时,jQuery抓取数据幻灯片并使用该信息来查找匹配的ID并应用一个类。使用此选项和变量的多个选择器
<div class="service-link" data-slide="#post-123">Click Me</div>
当我在同一行上使用'this'和target时,'target'没有得到应用于它的活动类。
$(this, target).addClass("active");
它工作,如果我使用两行。任何人都知道我为什么不能使用一条线?
$(this).addClass("active");
$(target).addClass("active");
全部工作的脚本 -
$(".service-link").click(function(){
var target = $(this).data("slide");
$(".service-type-slide, .service-link").removeClass("active");
$(target).addClass("active");
$(this).addClass("active");
})`
这工作!谢谢!我发誓我尝试过。 – user2504370 2014-10-11 19:09:22