我想在我的if
语句中使用三个条件。这里是我的代码:如何在Jquery添加三个条件
<script>
jQuery(document).ready(function() {
var num_one; var num_two; var num_three;
$("#control").attr("disabled", "disabled");
$('#col-1 li').click(function(){ num_one = true; getState();});
$('#col-2 li').click(function(){ num_two = true; getState();});
$('#col-3 li').click(function(){ num_three = true; getState();});
function getState(){
if ((num_one == true) & (num_two == true) & (num_three == true)) {
$("#control").removeAttr("disabled");
}
}
/*$('#col-1 li').click(function(){$("#control").removeAttr("disabled");*/
});
/**$("#enableBtn").click(function() {
$("#clearBtn").removeAttr("disabled");
});**/
</script>
这是工作,当我用只有两个条件:if ((num_one == true) & (num_two == true))
但是当我添加第三个条件这是行不通的。如何在if语句中添加三个条件?
它适用于'如果(num_one && num_two){'和'如果(num_one && num_three){',但并没有对'如果(num_one && num_two && num_three)工作{ ' – ahkeno 2012-02-09 16:41:41
在此处运行良好:http://jsbin.com/eyogoj/edit – 2012-02-09 16:44:20