JS method of setting value: 1. Use innerHTML attribute, syntax "document.getElementById('id name').innerHTML=value"; 2. Use val() function, syntax "$(selector). val(value)".
The operating environment of this tutorial: Windows 7 system, JavaScript version 1.8.5, Dell G3 computer.
First type:
html document code is as follows:
js value method:
document.getElementById('name').innerHTML = data.name;
Second type
html The document code is as follows:
js value method:
var name = data.name; $('#name').val(name);
[Recommended learning:javascript advanced tutorial]
The above is the detailed content of How to set value in javascript. For more information, please follow other related articles on the PHP Chinese website!