0
请考虑此代码。文件就绪代码运行不止一次
单击按钮时,将“活动”类添加到此,并移除所有其他按钮。
我希望页面加载一个按钮设置与积极的类,但是当我把代码放在(文档).ready在顶部,每运行一次按钮被点击,(它应该被删除的第二个另一个按钮被点击
$(document).ready(function() {
$("#society-buttons-form .big-button :input").addClass('active');
});
//new jquery for buttons, does not lose class
$("#society-buttons-form .small-button :input, #society-buttons-form .big-button :input").hover(function(){
$(this).addClass("hoveractive");
},
function() {
$(this).removeClass("hoveractive");
}
);
$("#society-buttons-form .small-button :input, #society-buttons-form .big-button :input").click(function(){
$("#society-buttons-form .small-button :input, #society-buttons-form .big-button :input").removeClass('active');
$("#society-buttons-form :input, #society-buttons-form .big-button :input").removeClass('active');
// $("#society-buttons-form .big-button :input").removeClass('active');
$(this).addClass('active');
$(this).removeClass("hoveractive");
});
那些懒惰的选择器是什么? – elclanrs 2012-02-16 23:46:03
它需要强光两种按钮,顶部的一个大按钮和小按钮 – 2012-02-16 23:48:23