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

What are the commonly used output methods in js?

王林
王林forward
2020-04-30 09:15:403008browse

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这个文本框添加的内容";

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

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

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!

Statement:
This article is reproduced at:cnblogs.com. If there is any infringement, please contact admin@php.cn delete