jQuery easyui checkbox

easyui(jquery)中checkbox的几条:

1. jQuery 判断 checkbox 是否被选中的几种方法

//from http://szxatjp.blog.163.com/blog/static/101392539201310834930485/

example:

<input id=”q_real” type=”checkbox” value=”1″>查实配  </td>

<input id=”q_spare” type=”checkbox” value=”spare”>查应配  </td>

方法一:

if ($("#checkbox-id")get(0).checked) {
    // do something
}

方法二:

if($('#checkbox-id').is(':checked')) {
    // do something
}

方法三:

if ($('#checkbox-id').attr('checked')) {
    // do something
}
在easyui的查询参数里 我用了第二种方法判断,第三种好像不行。

2. 设置checkbox选中或不选中:
$('#q_real')._propAttr('checked',false);
例如:
<td align="left" width="30px">&nbsp;</td>
 <td align="left"><input id="q_real" type="checkbox" value="1" onclick="checkreal()">查实配 </td>
 <td align="left" width="30px">&nbsp;</td>
 <td align="left"><input id="q_spare" type="checkbox" value="2" onclick="checkspare()">查应配 </td>
 
<script>
function checkreal(){
 if($('#q_real').is(":checked")){
 $('#q_spare')._propAttr('checked',false);
 }
 }

 function checkspare(){
 if($('#q_spare').is(":checked")){
 $('#q_real')._propAttr('checked',false);
 }
 }
</script>
This entry was posted in Computer, Java. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s