0% found this document useful (0 votes)
8 views6 pages

JavaScript Basics and Output Methods

The document provides an introduction to JavaScript, highlighting its ability to manipulate HTML styles and display data in various ways, such as using innerHTML, document.write(), window.alert(), and console.log(). It emphasizes the importance of script placement for performance and notes that document.write() should only be used for testing. Additionally, it explains that the window object is the global scope in JavaScript, making the use of the window keyword optional.

Uploaded by

Swadeep Sachan
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views6 pages

JavaScript Basics and Output Methods

The document provides an introduction to JavaScript, highlighting its ability to manipulate HTML styles and display data in various ways, such as using innerHTML, document.write(), window.alert(), and console.log(). It emphasizes the importance of script placement for performance and notes that document.write() should only be used for testing. Additionally, it explains that the window object is the global scope in JavaScript, making the use of the window keyword optional.

Uploaded by

Swadeep Sachan
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

JavaScript-W3Schools

JavaScript Introduction:
-->

JavaScript Can Change HTML Styles (CSS)


HTML Content

Example
[Link]("demo").[Link]= "35px";

Try it Yourself »

--> [Link]("demo").[Link] = "none";


-->
HTML Content
Showing hidden HTML elements can also be done by changing the
display style:

Example
[Link]("demo").[Link]= "block";

Try it Yourself »

--> Placing scripts at the bottom of the <body> element improves the display speed, because
script interpretation slows down the display.
--> <script> tag can be placed in <head> and <body> or both
NOTE: External scripts cannot contain <script> tags.

JavaScript Output:
JavaScript Display Possibilities:
JavaScript can "display" data in different ways:
• Writing into an HTML element, using innerHTML .
• Writing into the HTML output using [Link]() .
• Writing into an alert box, using [Link]() .
• Writing into the browser console, using [Link]() .

Using [Link]()
NOTE: The [Link]() method should only be used for testing.
HTML Content
<!DOCTYPEhtml>
<html>
<body>

<h1>My First Web Page</h1>


<p>My first paragraph.</p>

<script>
[Link](5+ 6);
</script>

</body>
</html>

Try it Yourself »

--> Using [Link]() after an HTML document is loaded, will delete all existing HTML
HTML Content
Example
<!DOCTYPEhtml>
<html>
<body>

<h1>My First Web Page</h1>


<p>My first paragraph.</p>

<buttontype="button"onclick="[Link](5 + 6)">Try it</button>

</body>
</html>

Try it Yourself »

--> In above case,Once we click on "Try it" button the h1 and p elements content goes off
--------------------------------------------------------------------------------------------------------
-

Using [Link]()
HTML Content
Using [Link]()
You can use an alert box to display data:

Example
<!DOCTYPEhtml>
<html>
<body>

<h1>My First Web Page</h1>


<p>My first paragraph.</p>

<script>
[Link](5+ 6);
</script>

</body>
</html>

Try it Yourself »

--> You can skip the window keyword.


--> In JavaScript, the window object is the global scope object. This means that variables,
properties, and methods by default belong to the window object. This also means that
specifying the window keyword is optional

--------------------------------------------------------------------------------------------------------
-

Using [Link]():
For debugging purposes, you can call the [Link]() method in the browser to display
data.
HTML Content

Example
<!DOCTYPEhtml>
<html>
<body>

<script>
[Link](5+ 6);
</script>

</body>
</html>

Try it Yourself »

**we can call the [Link]() method in the browser to print the content of the current
window.
--> Simply our print command like printing the content of the browser

You might also like