Possible Duplicate:
Using JQuery to toggle between styles
当我说切换时,我并不是指toggle()函数。我将项目的css更改为单击功能上的任何内容,我想再次单击该项目并恢复为原始css。
$("#item").click(function(){
$("#item").css("border-color", "#A8402A");
});
最佳答案
不用内联修改样式,只需使用一个类:
CSS:
.active {
border-color: #A8402A;
}
$('#item').click(function() {
$(this).toggleClass('active');
});
关于jquery - jQuery切换操作,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13336247/