Home > Web Front-end > JS Tutorial > What are the commonly used output methods in js?

What are the commonly used output methods in js?

王林
Release: 2020-04-30 09:15:40
forward
3098 people have browsed it

What are the commonly used output methods in js?

1. alert("Content to be output");

->Pop up a dialog box in the browser and display the content to be output.

->alert first converts the content to be output into a string and then outputs it

2, document.write("Content to be output");

->Display the output content directly on the page

3. console.log("Content to be output");

->Output the content on the console

4. value ->Assign value content to the text box (form element)

->Get the content of the text box (form element)

document.getElementById("search").value = "要给#search这个文本框添加的内容";
Copy after login

5. innerHTML/innerText ->Assign value content to labels other than form elements

document.getElementById("div1").innerHTML = "吧啦吧啦吧啦吧啦"; 
document.getElementById("div1").innerText = "吧啦吧啦吧啦吧啦";
Copy after login

Recommended tutorial:js introductory tutorial

The above is the detailed content of What are the commonly used output methods in js?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
js
source:cnblogs.com
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