Jquery get form field value

前端 未结 8 2112
醉酒成梦
醉酒成梦 2020-12-01 07:13

I am using a jquery template to dynamically generate multiple elements on the same page. Each element looks like this

8条回答
  •  有刺的猬
    2020-12-01 07:41

    var textValue = $("input[type=text]").val()
    

    this will get all values of all text boxes. You can use methods like children, firstchild, etc to hone in. Like by form $('form[name=form1] input[type=text]') Easier to use IDs for targeting elements but if it's purely dynamic you can get all input values then loop through then with JS.

提交回复
热议问题