我需要在jQuery中获取复选框值。 这里是我的代码:获取jQuery中的复选框值?
$(document).ready(function() {
$('input[type="checkbox"]').bind('click',function() {
var tObj = $('#checkpermission');
var tVal = tObj.val();
alert(tVal);
});
});
$query="select * from tbl_user where username!='admin' and password!='admin' order by username limit $eu, $limit";
$result=mysql_query($query);
while($data=mysql_fetch_array($result)) {
<td><INPUT TYPE="checkbox" name="checkuser" id="checkpermission" onclick="changePage()" value='<?=$data[0]?>'></td>
<?php
}
每次我只得到了第一个值。什么做错了?
第一个值是什么?在SQL查询或jQuery选择器?我很困惑。 – jensgram 2012-01-11 08:15:29
它似乎你是混合JavaScript和PHP,这是你使用的真实代码? – Orentet 2012-01-11 08:15:48
查看'.val'的文档:http://api.jquery.com/val/ – 2012-01-11 08:27:43