+
95
-

回答

还可以通过e.isTrigger来判断,代码如下:

<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum=1.0,minimum=1.0,user-scalable=0" />

<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/jquery.17.js"></script>

<style>
</style>
</head>

<body>
<input type='checkbox' id='try'>try

<script type="text/javascript">
$(function() {

$('#try').change(function(e){
if (e.isTrigger)
{
alert ('not a human');
}else{
alert ('human');
}
});

$('#try').trigger('change'); //doesn't alert

});
</script>
</body>

</html>


网友回复

我知道答案,我要回答