0

Inside the browser I see a value in the #worktime input element. e.g. 7,6 This value gets set before by jQuery $("#worktime").val("7,6");

But when I look with firebug into this line of code I see no value:

<input id="worktime" value="" readonly="">

But under the DOM section in firebug I see for this element a value of "7,6".

If I want to print the #worktime value with alert no value shows up.

6
  • Can you reproduce this with a JS Fiddle? Is it in all browsers, or just Firefox? Commented Nov 5, 2013 at 19:44
  • 2
    Can you demonstrate this with complete code or a live example? How are you inspecting this in Firebug? The value, if set after the page loads, won't be in the page source but will be in the DOM. Commented Nov 5, 2013 at 19:44
  • It is set as the property value of the DOM element, it won't be reflected in the attribute value in the html. Commented Nov 5, 2013 at 19:45
  • Something like this ? jsfiddle.net/YNDaD Commented Nov 5, 2013 at 19:46
  • and how can i check if the value of the DOM element changes? Commented Nov 5, 2013 at 19:48

1 Answer 1

2

This is because there is a very large difference between the value property and the value attribute. The value attribute contains the default value of the input, while the value property contains the current value. The default value can also be found in the defaultValue property. changing the value does not change the value attribute or the defaultValue property.

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

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.