Get the App
SLTechnology News&Howtos  ›  Development  › 

How javascript outputs values

Shulou Source: shulou.com Published: 2022-06-03 17:02:22 09月22日 Update

This article mainly introduces how to output the value of javascript, the article introduces in great detail, has a certain reference value, interested friends must read it!

The method of output value: 1, use the "window.alert ('value')" statement to output through the pop-up window; 2, use the "element object .innerHtml =" output value "statement; 2, use the" [xss_clean] ("value") "statement; 4, use the" console.log ("value") "statement.

The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.

JavaScript output mode

1. Use window.alert () to pop up the warning box

Window.alert ('warning box')

2. Write to the HTML element using the element object .innerHtml = "value to be written"

To require JavaScript to access a HTML element, you can use the document.getElementById (id) method

Use the id attribute to identify the HTML element, and innerHTml to get or insert the element content:

My first paragraph

Document.getElementById ("demo") [xss_clean] = "paragraph modified"

Document.getElementById ("demo") is the JavaScript code that uses the id attribute to find the HTML element. This method is defined in HTML DOM.

InnerHTML = "Paragraph changed." Is the JavaScript code used to modify the HTML content (innerHTML) of an element.

3. Use the [xss_clean] () method to write the content to the html document

Use the [xss_clean] () method to write content to HTML content, which allows you to write content or html tags directly to an html document

[xss_clean] (Date ()); / / Date () exports China Standard time

Note: executing [xss_clean] () after the document has finished loading will overwrite the entire HTml page

Sample:

Tags: Elements content output methods statements documents browsers code objects attributes paragraphs articles values interests functions boys buddies buttons console Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker vpn Xiaomi Microsoft macOS