Jquery中checkbox单选效果
<script type="text/javascript">
$(function(){
$(':checkbox[name=check_comp]').each(function(){
$(this).click(function(){
if($(this).attr('checked')){
$(':checkbox[name=check_comp]').removeAttr('checked');
$(this).attr('checked','checked');
}
});
});
});
</script>
初始化弹窗内容和事件
//---------------------------弹窗-------------Start//
function openCompanySelect() {
$.dialog.setting.zIndex =9999;
$.dialog({content: 'url:companyController.do?compSelect', zIndex: 2100, title: '公司列表', lock: true, width: '800px', height: '600px', opacity: 0.4, button: [
{name: '<t:mutiLanglangKey="common.confirm"/>', callback:callbackCompanySelect, focus: true},
{name: '<t:mutiLanglangKey="common.cancel"/>', callback: function (){}}
]}).zindex();
}
function callbackCompanySelect() {
//得到弹出对话框对象
var iframe = this.iframe.contentWindow;
//得到弹出框里的具体选择的对象
var ckObj = iframe.$(".chkCompId");//注意使用。尽量避免使用id 获取id对应的所有对象。也就是本来id 应该唯一,若多个id重复,只选择第一个符合的对象。此处使用class
//遍历对象
for(var i=0;i<ckObj.length;i++){
//对象被选中
if(ckObj[i].checked == true){
alert(ckObj[i].value);
$("#companyId").val(ckObj[i].value);
}
}
}
function callbackClean(){
$('#companyId').val('');
}