当值设置为输入字段时,西班牙文本不能正确显示 [英] Spanish text is not displayed properly when value is set to input field
本文介绍了当值设置为输入字段时,西班牙文本不能正确显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将西班牙文本设置为输入字段,但似乎没有正确显示。
但是,如果文本在div内,或者它已经设置为输入字段的值,则相同的文本显示为罚款。
HTML
< div> Cuenta de Ahorros Persona F& iacute; sica< / div>
< input id =txt2type =textvalue =Cuenta de Ahorros Persona F& iacute; sica/>
< input id =txttype =textvalue =/>
JS
$('#txt')。val('Cuenta de Ahorros Persona F& iacute; sica'); //不能正常工作
小提琴: http://jsfiddle.net/v8p0efzx/
解决方案
($('< div>')。html('$ t $')是使用
Cuenta de Ahorros Persona F& iacute; sica')。text());
I'm trying to set a spanish text to a input field and it doesn't seem to show up properly. But the same text shows up fine if its inside a div or when it is already set as a value to input field.
HTML
<div>Cuenta de Ahorros Persona Física</div>
<input id="txt2" type="text" value="Cuenta de Ahorros Persona Física" />
<input id="txt" type="text" value="" />
JS
$('#txt').val('Cuenta de Ahorros Persona Física'); //does not work properly
Fiddle : http://jsfiddle.net/v8p0efzx/
解决方案
The trick is to use
$('#txt').val($('<div>').html('Cuenta de Ahorros Persona Física').text());
这篇关于当值设置为输入字段时,西班牙文本不能正确显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文