Reputation: 293
I have an <input>
element which is loaded with a default value. Later on, i change that value via jQuery's input.val("different value")
.
When I console.log() the element, I see this in firebug:
Object[input.cs_required.form-control.input-sm property value = "12/29/2014" attribute value = "12/02/2014"]
Upvotes: 0
Views: 2789
Reputation: 817218
As you said, you are providing a default value via the value
HTML attribute. That will be the initial value of the DOM element's value
property. Changing the propery does not affect the attribute.
The value of HTML attributes is often used as initial value for the corresponding DOM property.
Upvotes: 1
Reputation: 4324
Quick example of the difference:
jQuery('#something').val()
changes the *.value property.
jQuery('#something').attr('value','neValue')
changes the attribute on that component.
There is an important difference between the two. Take a look at this for more info.
What's the difference between jQuery .val() and .attr('value')?
The only thing you have to worry about is whether you are using/assigning/utilizing the correct item - property or attribute
.
Upvotes: 1