0

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.

2
  • 1
    You're a bit off amp-what.com/unicode/search/pound Commented Jan 9, 2014 at 15:56
  • 1
    It's var, not val when you create a variable ? Commented Jan 9, 2014 at 15:59

2 Answers 2

2

HTML entities doesn't work as a value in inputs, they are only converted when used in the HTML, use the character directly:

var NewPrice1 = '2.5';
jQuery('#price_product_field').val('£' + NewPrice1);

http://jsfiddle.net/AaU2J/

Sign up to request clarification or add additional context in comments.

2 Comments

Tried that but it add this sign "Â" before the "£" sign
@user2001411 - Then you're not using the correct character encoding for your site, it should be UTF8
0

Try :

var NewPrice1 = '2.5'; jQuery('#price_product_field').html('£' + NewPrice1);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.