好好学习,天天向上!

jQuery函数使用记录

2020-03-04

closest()当点击确认按钮时,需要获取表单内容,此时就需要这个函数来查找他的指定父级元素.....

$(this).closest("tr").find(".lotNo").val(str);

 

获取div中所有表单内容,并组成对象:

$("#btnRegister").on("click", function () {
    var $this = $(this).closest("div");
    var data = {};
    $this.find("input").each(function () {
        data[$(this).attr("name")] = $(this).val();
    })
    console.log(data);

    //这种方法太土
    //data.loginid = $this.find("#regLoginId").val()
    //data.companyname = $this.find("#regCompanyName").val()
    //data.password = $this.find("#regPassword").val()
    //data.password2 = $this.find("#regPassword2").val()

})

 

posted @ 2020-03-04 14:39  刘下来  阅读(139)  评论(0编辑  收藏  举报