- Using Console
- Using Dialog Box
- Writing to HTML Elements
- Writing to the Browser Window
Programming Examples of Using Console Output; –
You can see above console.log program. However, the output of console.log() cannot be seen on mobile devices because the developer console is only available on desktop devices browser like Firefox, Microsoft Edge and Firefox.
Using Dialog Box
In Dialog Box, we display output by using alert() function, we can output data on a dialog box, and it is work both mobile and desktop, Look below programming example.
Programming example using Dialog Box; –
If you run above programming example, then you can see a dialog box like given below;
This is the output of the above programming examples, print output using Dialog box.
Writing to HTML Elements
By using this Writing HTML Elements, innerHTML property, we can change the content or text of the selected elements.
We can use the document.getElementById() function to select an elements. Look below programming example to understand better.
Programming example of Inner HTML; –
You can see the above programming of Inner HTML coding, in output of this program if you click the button the sum of number is show over the button, like below output image.
This is the output of above programming examples; –
Writing to the Browser Window
By using the document.write() function to display the output. We can write to the content of the document. Now see the programming examples below to better understanding.
Programming examples of Displaying Browser Window; –
You can see above programming, in output of this program if you click the button when the sum of number (25) is print in the place of button. You can see below the output image.
Read Also –
- Learn Modern Computer Skills
- Learn all Tutorial of HTML With Programming Examples.