jquery 表单点击提交及验证常用写法 jquery获取元素
2021-12-30 本文已影响0人
shine001
获取元素属性
<p><a href="//www.runoob.com" id="runoob">菜鸟教程</a></p>
$("#runoob").attr("id")
值为runoob
点击关闭按钮页面重新加载
$(".close").on("click", function() {
window.location.reload();
})
$("#submit").unbind("click").on("click", function() {
$("#submit").attr("disabled", "disabled");
var area = $("#area").val();
if (area == '') {
alert("请选择222");
return;
}
var schoolname = $("#schoolname").val();
if (schoolname == '') {
alert("请填写11");
return;
}
var credit_code = $("#credit_code").val();
if (credit_code == '') {
alert("请填写222");
return;
}
var goods_amount = parseFloat($("#goods_amount").val());
if (isNaN(goods_amount) || goods_amount <= 0) {
alert("111误,请重新填写");
return;
}
if (confirm("是否确定提交")) {
var data = {
"act": "gwksubmit",
"area": area,
"schoolname": schoolname,
"credit_code": credit_code,
"goods_amount": goods_amount,
"user_id": user_id,
"remark": remark
};
$.post("xxx.php", data, function(d) {
//$(".popBox").css('display':'block'); // display: flex;
$(".popBox").css('display', 'block');
})
}