JavaScript document.write() method
JavaScript document.write is one of the functions in the Document object collection. Through document.write, you can easily write the string content where you want to display text on the web page. When you are writing HTML , To display a paragraph of text on a web page, the easiest way is to write the string directly in HTML . In fact, you can also use the document.write() method of JavaScript to do it. Not only a string, but also contains HTML tags, such as wrapping or displaying images.
JavaScript document.write() basic syntax
document.write('Write the text you want to present here');
Place the text content to be presented in document.write parentheses, and use single quotes (") or double quotes ("") to wrap the string so that the browser will automatically present the text as a string. If you The text content to be presented is a variable, so it cannot be directly placed in quotation marks. A comma (,) or plus sign (+) must be used to connect the variable number string. When there are many variables, it is recommended to use the plus sign (+). Concatenate the variable number string to avoid display errors caused by the browser's judgment error.JavaScript document.write example 1. Simple display string
document.write("This is the test page content");
</script>
var TestString='Have a good time.';
document.write('Welcome to Wibibi.<br>'+TestString);
</script>
Have a good time.
Post a Comment
0 Comments