开发者

How to set the text of a submit button using JQuery?

开发者 https://www.devze.com 2022-12-20 20:26 出处:网络
For some reason $(\"#thebutton\").val(\"New t开发者_StackOverflow中文版ext\") doesn\'t work.Well, this works for me (tested on Chrome 4, FireFox 3.6, IE8):

For some reason $("#thebutton").val("New t开发者_StackOverflow中文版ext") doesn't work.


Well, this works for me (tested on Chrome 4, FireFox 3.6, IE8):

<html>
<head>
    <title>Test</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
    <script type="text/javascript">
    $(function() {
        $("#thebutton").val("New text");
    });
    </script>
</head>
<body>
    <input id="thebutton" type="submit" value="OK" />
</body>
</html>


If you are using html button i.e. <button id='thebutton ' > Button Val </button> then use $("#thebutton").text("NEW Text");

0

精彩评论

暂无评论...
验证码 换一张
取 消