In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Today, I will talk to you about how JavaScript is output. maybe many people don't know much about it. In order to make you understand better, the editor summed up the following content for you. I hope you can get something according to this article.
JavaScript is the most popular scripting language on the Internet, which can be used in HTML and web, and can be widely used in devices such as servers, PC, laptops, tablets and smartphones. JavaScript does not have any functions for printing or outputting.
JavaScript display data
JavaScript can export data in different ways:
Use window.alert () to pop up the alert box.
Use the [xss_clean] () method to write the content to the HTML document.
Use innerHTML to write to the HTML element.
Use console.log () to write to the browser's console.
Use window.alert ()
You can pop up a warning box to display the data:
Example
My first page
My first paragraph.
Window.alert (5 + 6)
Manipulate HTML elements
To access a HTML element from JavaScript, 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:
Example
My first Web page, my first paragraph.
Document.getElementById ("demo") [xss_clean] = "paragraph has been modified."
The above JavaScript statement (in the tag) can be executed in a web browser:
Document.getElementById ("demo") is the JavaScript code that uses the id attribute to find the HTML element.
InnerHTML = "paragraph has been modified." Is the JavaScript code used to modify the HTML content (innerHTML) of an element.
In this tutorial
In most cases, in this tutorial, we will use the methods described above to output:
The above example directly translates the id= "demo"
The element is written to the HTML document output:
Write to HTML document
For testing purposes, you can write the JavaScript directly in the HTML document:
Example
My first Web page
My first paragraph.
[xss_clean] (Date ())
Please use [xss_clean] () to output only what is written to the document.
If you execute [xss_clean] after the document has finished loading, the entire HTML page will be overwritten.
Example
My first Web page
My first paragraph.
"myFunction ()" > click function myFunction () {[xss_clean] (Date ());}
Write to the console
If your browser supports debugging, you can use the console.log () method to display the JavaScript value in the browser.
Use F12 in the browser to enable debug mode, and click the "Console" menu in the debug window.
My first Web page a = 5 / b = 6 / c = a + b / b / console.log (c)
Screenshot of instance console:
After reading the above, do you have any further understanding of how JavaScript is output? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.