Home > WeChat Applet > Mini Program Development > WeChat applet-get user input content

WeChat applet-get user input content

高洛峰
Release: 2017-02-25 09:34:14
Original
2468 people have browsed it

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="请输入邮箱地址" />
Copy after login

test.js

##

var inputContent = {}
Page({
 data: {
 inputContent: {}
 },
 bindChange: function(e) {
 inputContent[e.currentTarget.id] = e.detail.value
 }
})
Copy after login

Background output


WeChat applet-get user input content

For more WeChat applet-related articles on obtaining user input content, please pay attention to the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template