javascript - Is there (should there be) any difference between native js defaultValue and jQuery prop(defaultValue)? -


i'm litte confused native javascript defaultvalue functionality. have understood value of html input must set , value initial default value.

i wanted restore specific input (text) element default value when have inside click-event. (cancel button)

//restore values var name_person = $(this).find('.nameofperson');         //attempt 1 name_person.val(name_person.defaultvalue); alert('restored value=' + name_person.val()); //this alerts nothing  //attempt 2 name_person.val(name_person.prop('defaultvalue')); //this alerts default value alert('restored value=' + name_person.val()); 

why doesn't native defaultvalue attribute work when prop('defaultvalue') does? shouldn't same? initial value set value="bla bla bla" in input element.

i got work (with jquery), wonder - missing something?

it not work because name_person jquery object , jquery not have defaultvalue. need reference dom object

name_person[0].defaultvalue 

or

name_person.get(0).defaultvalue 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -