.val()
works on input elements (or any element with a value attribute?) and .text()
will not work on input elements.
(.val()
适用于输入元素(或任何带有value属性的元素?)和.text()
不适用于输入元素。)
.val()
gets the value of the input element -- regardless of type.(.val()
获取input元素的值 - 无论类型如何。)
.text()
gets the innerText (not HTML) of all the matched elements:(.text()
获取所有匹配元素的innerText(而不是HTML):)
.text()
The result is a string that contains the combined text contents of all matched elements.
(结果是一个字符串,其中包含所有匹配元素的组合文本内容。)
This method works on both HTML and XML documents.(此方法适用于HTML和XML文档。)
Cannot be used on input elements.(不能用于输入元素。)
For input field text use the val attribute.(对于输入字段文本,请使用val属性。)
.val()
Get the content of the value attribute of the first matched element
(获取第一个匹配元素的value属性的内容)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…