[英]jQuery use HTML code input text field
I have an input type="text" field and I want to display the pound sign and then a value 我有一个输入类型=“文本”字段,我想显示英镑符号,然后显示一个值
Using 运用
val NewPrice1 = '2.5';
jQuery('#price_product_field').val('£' + NewPrice1);
But it just displays £ inside the box instead of the actual pound sign. 但它只是在框内显示£而不是实际的英镑符号。
HTML entities doesn't work as a value in inputs, they are only converted when used in the HTML, use the character directly: HTML实体不能作为输入中的值使用,只有在HTML中使用时才会转换它们,直接使用字符:
var NewPrice1 = '2.5';
jQuery('#price_product_field').val('£' + NewPrice1);
试试:
var NewPrice1 = '2.5'; jQuery('#price_product_field').html('£' + NewPrice1);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.