Sunday, June 2, 2024
 Popular · Latest · Hot · Upcoming
27
rated 0 times [  32] [ 5]  / answers: 1 / hits: 31928  / 9 Years ago, tue, july 28, 2015, 12:00:00

I have a text box as



HTML



<input type=text id=lat placeholder=Latitude ng-lat value=9&#176;> 


which works fine as it displays the degree sign perfectly, but when I try to set the value through jquery like



Jquery



$(#lat).val(9&#176;)



Its displaying the entire text instead of the degree symbol.


More From » jquery

 Answers
17

You can target the value attribute:



$(#lat).attr('value',101+String.fromCharCode(176))


it is also better to use .text() to set the text because .val() is used to retrieve the value of an element


[#65649] Saturday, July 25, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
blair

Total Points: 384
Total Questions: 108
Total Answers: 86

Location: Northern Ireland
Member since Tue, May 5, 2020
4 Years ago
;