Hello guys, till now I have a basic knowledge of JavaScript. If didn’t read or learn this article so click on this link,https://smgplaza.com/category/javascript/.
Now In this article, you can see the method/Display possibilities, statement, and syntax. Also, for this you may learn basic HTML so that prefer this to understand the hole HTML language, so link – https://techiebot55.blogspot.
JavaScript display possibilities.
In this 4 related method here is like, innerHTML, document.write(), window.alert(), console.log(). For access the data. JavaScript can use the document.getElementById(id) method. In id attribute define a html element and also fecth the data to the Html page. The innerHTML() define as a html content.
innerHTml method.
For this simply create one html file and and for access the data for html file you may create one id like, <p id=”demo”></p> and then inside the script tag call the id attribute.
syntax is like – document.getElementById(“demo”).innerHTML=2+2;
document.write method.
In this method no need to create any attribute for fetch or access the data, because in this method no need to create an id or content for accessing to the data. in this automatic browser can access the which write in the document.write() box inside the script tag .
For syntax like this – document.write(2+2); .
window.alert() method.
In this method, if you can use an alert box to display data. also, you can skip this window word. It not necessary to write a word. In this window, word specifies as a keyword. This window object is a global scope object, which means by default variable, keywords, properties belong to the window object.
For this syntax is like – alert(2+2); so output given in the alert box.
console.log() method.
In this method, you can call the window.log() method in the browser to display the data. For this it’s simply written console.log(2+2);
JavaScript Print() function.
JavaScript doesn’t have any print object or print methods. The only exception is that you can call the window.print() method in the browser to print the content of the current window. The example is given below –
<html> <body> <h2>The window.print() Method</h2> <p>Click the button to print.</p> <button onclick="window.print()">Print the page</button> </body> </html>
output is like :-
Also, visit these articles:-
- How To Get Started With Python?
- How To Create A Python Snake Game Using Pygame.
- Best Free Games For PC In 2020
- How To Chrome OS Install On PC.
If you have any doubts any suggestions or any query DM us one below Social media handles.
Our Social Media Handles:-
Instagram Handle :- https://www.instagram.com/smgplaza/
Twitter Handle :- https://twitter.com/smgplaza
Thank you so much. You have to follow us using your mail id and also follow us on social media for more updates.