从输入标签的“提交”更改文本


102

我有一个标签<input type="submit" class="like"/>。我希望按钮内的文本显示为“赞”,但现在它显示为“提交”。

class="like" 顺便说一下,是按钮的CSS。

Answers:


163

-type 元素value上的属性控制显示的文本。submit<input>

<input type="submit" class="like" value="Like" />

优秀,并指向重点。推荐阅读下面有关Quentin的答案,有关在尝试获取元素值时使用inputvs 的问题button
Govind Rai

万分感谢!!对于这个答案。非常需要
Tessaracter19年

28

value属性用于确定提交输入的呈现标签。

<input type="submit" class="like" value="Like" />

请注意,如果控件成功(该控件不会成功,则不会成功name)也将是该控件的提交值。

要获得不同的提交值和标签,您需要使用button元素,其中元素内部的textNode确定标签。您可以包括其他元素(包括<img>此处)。

<button type="submit" class="like" name="foo" value="bar">Like</button>

请注意,<button>在较旧版本的Internet Explorer中,对的支持不可靠。


0
<input name="submitBnt" type="submit" value="like"/>

$_POST在php和javascript中使用时,name很有用document.getElementByName('submitBnt')。您也可以使用name作为CS选择器,例如input[name="submitBnt"]; 希望这可以帮助

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.