


document.write() and its output content style and position control_javascript skills
May 16, 2016 pm 05:26 PMOne of the most basic commands in JS: document.write(), used to simply print content onto the page. You can print the content you need word for word - document.write("content"), where content is what needs to be output. content; of course there is another situation where you need to output changes in JS such as variables, etc., then you need to use document.write(variable); of course variable is the variable you want to output.
Since you can output variables, you will definitely want to control the display of variables, such as position and style. The first control method is to add styles inside the application, such as
document.write("=font-size:20px;font-family= Helvetica;"content"" like this, However, if there are too many styles to be added, it will not only appear bloated, but also inconvenient to modify.
In this case, it will definitely feel better to use a selector. Various double quotes and single quotes are used, so when using them, attention should be paid to preventing early matching of double quotes and single quotes. The way I avoid it is to use " to remind the browser not to match prematurely. The example is as follows:
document.write("
Here defines an ID selector named ok to control the style, because the id name needs to be enclosed in double quotes , so in order to avoid matching the previous double quotes, use " to declare it, and then in the CSS file
#ok{style;}
you can define what you want Style and location too.

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Win11 startup path and how to open it

Details on how to turn on environment variable settings on Windows 11

where is windows10 credential manager

macOS: How to change the color of desktop widgets

Understand the location and structure of pip installation package storage

How to change the location of Gaode Map Home

Where is Kuaishou published and how to change its location? How to add a location to a video that has been uploaded?

Location of Origami Bird at Stardome Railway Crocker Film and Television Park
