1、jquery 操作HTML标签
复制代码 代码示例:
var val=$('input:radio[name="invoice.hasSend"]:
checked').val();
if(val == '2'){
var r=confirm("选择否,发票信息将清空,确定?");
if (r==true)
{
$('input:radio[name="invoice.invoiceType"]').removeAttr("checked");
$('textarea[name="invoice.remark"]').html("");
$('input:radio[name="invoice.invoiceType"]').attr("
disabled","true");
$('textarea[name="invoice.remark"]').attr("disabled","true");
}else{
return;
}
}else{
$('input:radio[name="invoice.invoiceType"]').removeAttr("disabled");
$('textarea[name="invoice.remark"]').removeAttr("disabled");
}
2、Jquery动态添加验证
复制代码 代码示例:
if(cc == 7){
$("select[name^='register.shipCity']").rules("add", {
required: true,maxlength:20});
$("input[name^='register.shipName']").rules("add", { required: true,maxlength:20});
$("textarea[name^='register.remark']").rules("add", { maxlength:200});
$("#invoiceTab").show();
}else{
$("select[name^='register.shipCity']").rules("remove");
$("input[name^='register.shipName']").rules("remove");
$("textarea[name^='register.remark']").rules("remove");
$("#invoiceTab").hide();
}
3、Jquery判断是否验证通过
复制代码 代码示例:
var r = $('#user400form').valid();
// alert(r);
if(r){
$('#btnid').attr({'disabled':true});
$("#user400form").submit();
}
三段jquery小代码,希望对大家有所帮助。