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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14007613/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 04:32:09  来源:igfitidea点击:

Change text from "Submit" on input tag

html

提问by user1261817

I have a tag, <input type="submit" class="like"/>. I want to have the text inside the button say "Like", but right now, it says "Submit".

我有一个标签,<input type="submit" class="like"/>。我想让按钮内的文字说“喜欢”,但现在,它说“提交”。

class="like"is the CSS of the button, by the way.

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

回答by Ry-

The valueattribute on submit-type <input>elements controls the text displayed.

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

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

回答by Quentin

The valueattribute is used to determine the rendered label of a submit input.

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

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

Note that if the control is successful (this one won't be as it has no name) this will also be the submitted value for it.

请注意,如果控件成功(这个控件不会是因为它没有name),这也将是它提交的值。

To have a different submitted value and label you need to use a button element, in which the textNode inside the element determines the label. You can include other elements (including <img>here).

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

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

Note that support for <button>is dodgy in older versions of Internet Explorer.

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

回答by bashleigh

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

name is useful when using $_POSTin php and also in javascript as document.getElementByName('submitBnt'). Also you can use name as a CS selector like input[name="submitBnt"]; Hope this helps

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