Soft technology leads you to learn the front end: Javascript output

Time:2019-10-19

JavaScript does not provide any built-in print or display functions.

JavaScript display scheme

JavaScript can “display” data in different ways:

  • UseWindow. Alert(), write warning box
  • UseDocument. Write(), write HTML output
  • UseInnerHTML writes HTML elements
  • UseConsole. Log(), write to browser console

Using innerHTML

To access HTML elements, JavaScript uses theDocument.getelementbyid (ID) method.

The ID attribute defines the HTML element. The innerHTML property defines HTML content:

Example

My first web page

My first paragraph




 document.getElementById("demo").innerHTML = 5 + 6;

Use document. Write()

For testing purposes, use theDocument. Write(), which is convenient:

My first web page

My first paragraph


document.write(5 + 6);

Use window. Alert()

You can use the warning box to display data:

Example

My first web page

My first paragraph


window.alert(5 + 6);

Use console. Log ()

In the browser, you can use theConsole. Log () method to display the data.

Use F12 to activate the browser console and select console from the menu

My first web page

My first paragraph


console.log(5 + 6);

Source: Soft Technology (www.sysoft. Net. CN)

Recommended Today

Query SAP multiple database table sizes

Query SAP multiple database table sizes https://www.cnblogs.com/ken-yu/p/12973009.html Item code db02 Here are two approaches, In the first graphical interface, the results of the query data table are displayed in MB, and only one table can be queried at a time. SPACE—Segments—Detailed Analysis—Detailed Analysis  In the pop-up window segment / object, enter the name of the […]