将提交按钮值替换为ASCII字符 [英] Replace submit button value with ASCII character

查看:91
本文介绍了将提交按钮值替换为ASCII字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用—(-)之类的ASCII字符代码替换提交"按钮的保存"值,不同的是它显示的是文字代码而不是其翻译.

I'm trying to replace the "save" value of the submit button with an ASCII character code like — (—), except it's displaying the literal code instead of its translation.

$("#myform").on("submit", function(){
    $("input#commit").attr('readonly', true).val("—");
});

产生这样的按钮:

[ — ]

我也尝试过.prop('value', '—');,但是同样的问题.这有可能吗?

I also tried .prop('value', '—'); but same problem. Is this even possible?

推荐答案

只需在值中使用字符,如下所示:

Just use the character in the value, like this:

$("#myform").on("submit", function(){
    $("input#commit").attr('readonly', true).val("—");
});

或者,也可以像这样使用unicode值:

or alternatively, use the unicode value like this:

$("#myform").on("submit", function(){
    $("input#commit").attr('readonly', true).val('\u2014');
});

这篇关于将提交按钮值替换为ASCII字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆