jQuery .val change doesn't change input value
Use attr
instead.
$('#link').attr('value', 'new value');
demo
Changing the value property does not change the defaultValue
. In the code (retrieved with .html()
or innerHTML
) the value attribute will contain the defaultValue
, not the value property.
to expand a bit on Ricardo's answer: https://stackoverflow.com/a/11873775/7672426
http://api.jquery.com/val/#val2
about val()
Setting values using this method (or using the native value property) does not cause the dispatch of the change event. For this reason, the relevant event handlers will not be executed. If you want to execute them, you should call .trigger( "change" ) after setting the value.