jquery点击li,判断复选框是否选中,结果打印结果出现false和true两种,是哪里错了?
代码如下:
html>
<html>
<head>
<meta charset="utf-8">
<title>title>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.1.1.min.js">script>
head>
<body>
<ul class="qul">
<li>
<label>
<input type="checkbox">
<span>测试span>
label>
li>
ul>
<script>
$('.qul li').click(function(){
var isChecked=$(this).find('input').prop('checked');
console.log(isChecked);
});
script>
body>
html>
打印结果如图
输出后加句return false;
你点击的时候是没有点中那个框,而是点了文字,就会先打印false,再打印true