Home > Web Front-end > JS Tutorial > body text

How to set value in javascript

醉折花枝作酒筹
Release: 2021-04-16 15:55:00
Original
3426 people have browsed it

JS method of setting value: 1. Use innerHTML attribute, syntax "document.getElementById('id name').innerHTML=value"; 2. Use val() function, syntax "$(selector). val(value)".

How to set value in javascript

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>
Copy after login

js value method:

document.getElementById(&#39;name&#39;).innerHTML = data.name;
Copy after login

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>
Copy after login

js value method:

var name = data.name;
$(&#39;#name&#39;).val(name);
Copy after login

[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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template