[英]Locating user input from a form and assigning it to a property
I have a form, that takes user[name, age, photo], as inputs of type text. 我有一个表单,它以user [name,age,photo]作为文本类型的输入。 I want to locate it the input in the HTML and then assign it to a property; 我想在HTML中找到输入,然后将其分配给属性;
newProductData.name = $('#new-product-name').val;
I used this, but newProduct.name, doesn't get assigned the value, which would be say for instance "ibrahim". 我用了这个,但是newProduct.name并没有被赋值,例如“ ibrahim”。 How would I go about getting the string value entered into the form, and assigning it as a property. 我将如何将字符串值输入表单,并将其分配为属性。
You need to call the function actually instead of just referencing it. 您需要实际调用该函数,而不仅仅是引用它。 Add ()
: 加()
:
newProductData.name = $('#new-product-name').val();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.