How to set value in javascript

醉折花枝作酒筹
Release: 2021-04-16 15:55:00
Original
3320 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:


        
Copy after login

js value method:

document.getElementById('name').innerHTML = data.name;
Copy after login

Second type

html The document code is as follows:

Copy after login

js value method:

var name = data.name; $('#name').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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!