【发布时间】:2013-09-25 19:50:55
【问题描述】:
为什么这个小提琴不起作用?有趣..
$(document).ready(function(){
$(".box").click(function(){
if ($(".box").css("background-color") == "red")
{
$(".box").html("Success!");
}
});
});
【问题讨论】:
-
console.log()是你的朋友。尝试做console.log($('.box').css('background-color'))看看它会返回什么。 -
很高兴。 a 上面的代码显示缺乏努力。查看 jQuery api 可以轻松解决
background和string问题。 -
不赞成票的原因是您上面的示例代码中的警报会告诉您 if 检查失败的确切原因。
标签: javascript jquery css