我尝试使用 .one 功能(按照http://jsfiddle.net/cse_tushar/FcvaD/83/上的示例)按下按钮后,将更改添加/删除更改为我的页面样式但是我的事件似乎没有解雇,任何想法可能会出错?
function handler1() {
$("body").css("background-color","#000000");
$(".ht").css("color","#fff");
$(".fb, .sht").css("color","#ccc");
var filename = window.location.href.substr(window.location.href.lastIndexOf("/")+1);
if ((filename == "j.html" || filename == "s.html")) {
// TODO: add comment
$("#logo").css("color","#fff");
}
}
function handler2() {
$("body, .ht, .fb, #logo").removeAttr('style');
}
$("#contrastIcon").one("click", handler2);
Jsfiddle:http://jsfiddle.net/L32p5Lge/