Home > Article > WeChat Applet > WeChat applet-get user input content
In the WeChat applet, how to obtain the content input by the user? ?
js: document.getElementById("Content").value
jq: $("#Content").val()
cannot be written like this in the WeChat applet.
You can store the user input through the bindchange attribute of the component
test.wxml
<input id="postalCode" bindchange="bindChange" type="number" placeholder="输入邮政编码" auto-focus /> <input id="mail" bindchange="bindChange" type="number" placeholder="请输入邮箱地址" />
test.js
##
var inputContent = {} Page({ data: { inputContent: {} }, bindChange: function(e) { inputContent[e.currentTarget.id] = e.detail.value } })Background output