Common JS output methods (5) and js output methods
I can work for you without much nonsense. The details are as follows:
1. alert ("content to be output ");
-> A dialog box is displayed in the browser, and the content to be output is displayed.
-> Alert converts the content to be output to a string and then
2. document. write ("content to be output ");
-> Directly display the output content on the page
3. console. log ("content to be output ");
-> Output content on the console
4. value-> assign values to the text box (Form element)
-> Get the content of the text box (Form element)
Document. getElementById ("search"). value = "content to be added to the # search text box ";
5. innerHTML/innerText-> assign values to tags except form elements
Document. getElementById ("div1"). innerHTML = "alright ";
Document. getElementById ("div1"). innerText = "alright ";
-> Differences Between innerHTML and innerText
1) When innerHTML is assigned a value, if a valid HTML Tag is processed as a real tag, the tag can play its own role;
InnerText whether or not labels are assigned values as text, all the values are text, and tags do not play their own role;
(When assigning values, innerHTML can recognize HTML tags, but innerText cannot)
2) innerText is not supported in some Firefox browsers, while innerHTML is supported by all browsers.