Home >Web Front-end >JS Tutorial >How to set value in javascript
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:
<td style="border:1px solid #c0c0c0;" id="name"></td>
js value method:
document.getElementById('name').innerHTML = data.name;
Second type
html The document code is as follows:
<td><input type="text" id="name" class="easyui-validatebox" style="width:150px;" data-options="required:true" /></td>
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!