Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How javascript outputs values

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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:

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report