admin管理员组文章数量:1289384
I'm trying to set a button value to be « (or ») via JavaScript with the following code:
document.getElementById('hideButton').value='«';
This just sets the button text to «
rather than «.
The HTML markup works fine (i.e. <input type="button" value="«">
) giving the double left arrow quote on the button face.
Is there some special way of escaping the ampersand code in JavaScript?
Thanks,
FM
I'm trying to set a button value to be « (or ») via JavaScript with the following code:
document.getElementById('hideButton').value='«';
This just sets the button text to «
rather than «.
The HTML markup works fine (i.e. <input type="button" value="«">
) giving the double left arrow quote on the button face.
Is there some special way of escaping the ampersand code in JavaScript?
Thanks,
FM
Share Improve this question edited Mar 27, 2014 at 10:19 niksvp 5,5632 gold badges27 silver badges43 bronze badges asked Mar 27, 2014 at 10:15 Fat MonkFat Monk 2,2651 gold badge30 silver badges73 bronze badges 2- Sorry, that was a typo in the question... I've added the extra ; in the question but it was already in my code. – Fat Monk Commented Mar 27, 2014 at 10:19
- you want to set some text for button face? – Savaratkar Commented Mar 27, 2014 at 10:23
3 Answers
Reset to default 10here just convert to UTF it should work.
document.getElementById('hideButton').value='\u00AB';
document.getElementById('otherButton').value='\u00BB';
here a link to convert special text
couldn't you just do this?
document.getElementById("hideButton").value = "«";
Sorry I would have just mented, but haven't got enough rep yet.
Alternatively, use the unicode \u00AB
http://jsfiddle/s53FH/
you could use the -element instead
<button id="hideButton"> </button>
<script>
document.getElementById('hideButton').innerHTML='«';
</script>
http://jsfiddle/6m3zz/
本文标签: htmlSetting a button value to contain an ampersand coded character via JavaScriptStack Overflow
版权声明:本文标题:html - Setting a button value to contain an ampersand coded character via JavaScript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741413697a2377383.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论