I don’t have much nonsense, so I just went to work for everyone. The details are as follows:
1. alert("the content to be output");
->A dialog box pops up in the browser and displays the content to be output.
->alert is used to convert the content to be output into a string and then output it
2. document.write("the content to be output");
->Directly display the output content on the page
3. console.log("content to be output");
->Output content in console
4. value -> Assign value to text box (form element)
-> Get the content of the text box (form element)
document.getElementById("search").value = "The content to be added to the #search text box";
5. innerHTML/innerText -> Assign value content to labels except form elements
document.getElementById("div1").innerHTML = "Balabarabarabarabarabara";
document.getElementById("div1").innerText = "Balabarabarabarabarabara";
->The difference between innerHTML and innerText
1) When assigning innerHTML values, if you encounter a valid HTML tag, you will treat it as a real tag, and the tag can play its own role;
Whether innerText is a tag or not, it is assigned as text. Then all you see is text, and the tag cannot play its own role;
(InnerHTML can recognize HTML tags when assigning values, but innerText cannot)
2) In some Firefox browsers, innerText is not supported, and innerHTML is supported by all browsers.