本文由 发布,转载请注明出处,如有问题请联系我们! 发布时间: 2021-05-06jquery如何获取checkbox的值和判断是否替换,表单的焦点事件
加载中//注册 短信关键词//单选框点周事件 $('#need_reg input[type="checkbox"]').change(function(){//判断是否选中 if($('#need_reg input[type="checkbox"]').attr("checked")){ $('#messagewords input[name="messagewords"]').removeAttr("disabled"); //表单移除disabled }else{ $('#messagewords input[name="messagewords"]').attr("disabled","disabled"); $('#messagewords input[name="messagewords"]').val(''); }}) $('input[name="type"]:checked').val(); //单选框选中的值 $('#messagewords input[name="messagewords"]').val(''); $('#need_reg input[type="checkbox"]').removeAttr("checked"); //多选框移除选择$('#messagewords input[name="messagewords"]').attr("disabled","disabled"); //选择$('#need_reg input[type="checkbox"]').attr("checked","checked");这是几种常见的单选框和多选框点击事件方法和获取值方法表单的焦点事件,验证 $('.process_name').bind({focus:function(){},blur:function(){ var process_name=$(this).val(); var ads_type=$('input[name="type"]:checked').val(); if (this.value == ""){ $(this).next('span').html('不能为空'); $(this).focus(); }else{ $.ajaxSetup({async:false}); $.getJSON( '?t='+Math.random(),{ "process_name":process_name,"type":ads_type },function(data){ if( data!=0 && data !=$('.ads_adid').html()){ $('.process_name').next('span').html('已被广告'+data+'占用'); $('.process_name').focus();}else{$('.process_name').next('span').html(''); } }); } } });