unknownbits
unknownbits

Reputation: 2885

hidden field value set by jquery?

My code setting text filed value like:

$('#chargetotal').val('20.00');

text field is:

<input type="text" id="chargetotal" value=""/>

After inspect element of my browser ,It looks like

<input type="text" id="chargetotal" value>

But the text filed has value 20.00.

My question is that,why am I getting this:

<input type="text" id="chargetotal" value>

I should get:

 <input type="text" id="chargetotal" value="20.00">  

Upvotes: 1

Views: 60

Answers (1)

Balachandran
Balachandran

Reputation: 9637

Using .val() wont change anything in the source while you inspect it since it is storing the value internally inside of the corresponding element object, if you want to reflect the changes in the source then you should use .attr('value','someValue').

Upvotes: 4

Related Questions