SMGPLAZA

Simple solution for complex problem

In this article we are discussing, What is JavaScript, Basic Introduction Of JavaScript. And How To Write Program In JavaScript With Some Examples. After This, We are covering All Topics In the Upcoming Article. If you want to learn HTML then you can follow this link https://techiebot55.blogspot.com/.

Introduction Of JavaScript

JavaScript and Java are completely different languages, both in concept and design. JavaScript was invented by Brendan Eich in 1995 and became an ECMA standard in 1997.

That is a programming language for web technology. It uses to change both HTML and CSS. It’s Allow You to Implement Some complex Features. JavaScript also is known as JS, This Is Object-Oriented Programming Language ( OOP ), also use to create a Dynamic Web page. This enables Interactive Mode and is a part of a web application.

JS is a lightweight programming language, And also JavaScript is case sensitive. Two waves to desired a JS, Internal and External

JavaScript Have Some Special Features are Below,

  • jQuery
  • AngularJS
  • JSON
  • AJAX
  • React

Where to put JavaScript.

JavaScript Code Is Insert Between <script> Tag. For this use type Attribute for the Js code. But Type Attribute is not require. JavaScript is the default scripting language in HTML. <script type=”text/JavaScript”>.

JavaScript Function and Event.

A function is a block of js code, that can be executed when “called” for the code. A function can be called when the t occurs and the user clicks the event button. JS can be put in the body as well as the head section of the HTML page. For creating a function or event syntax is like, function myfunction() {add the method of the js}, for calling the function or event must create a Button and then put on click of the created function. like,<button type=”button” onclick=”myfunction()”>… </button>

Two ways to write js code:-

  • you can include JS code internally in your HTML document.
  • you can write js code in a separate external file and call in your HTML document.
  • The First Internal script writes into the HTML document, the body part as well as the head section.
  • second External script code in a new file with the extension .js, add the code in your HTML document.
  • And just call the js file into the HTML document use the src attribute inside the <script> tag.you need specify the full path to your file in the src attribute. syntax <script src=”https://smgplaza.com/basic-of-javascript/data.js“> </script>
  • Also uses a full URL to link to a script.

Advantages of external JavaScript.

  • It separates HTML and codes.
  • It makes JavaScript easy to read and maintain.
  • A cached JavaScript file can speed up the page load.
  • Use more than script in a single HTML file.

To Change HTML content using JS Method.

JavaScript HTML method is document.getElemetById().innerHTML, This method is used to ” find ” HTML content Or Element By There Specific ID. Also, use to change the Declared HTML content, Example Is Given Below,

<html>
<body>

<h2>JAVASCRIPT</h2>

<p id="demo">JavaScript can change HTML content.</p>

<button type="button" onclick='document.getElementById("demo").innerHTML 
= "Welcome To SMGPLAZA"'>Click Me!</button>

</body>
</html>

You can Copy This Code And Paste In any code or Text editor And Just save with .html extension. That Gives one interface where You have one button when You click that, then the text has been changed.

Output 1:-
Output 2:-

Other methods to write JavaScript, using innerHTML, document.write(), window.alert, console.log. We converd this in next article.

Also visit this articles :-

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.

Riya Shah

Hey, I am Riya Shah. I am a Python developer. I am pursuing BTech. currently, I am in 2nd year. I am a blogger from India. I started blogging in Smgplaza to share my knowledge and more.

RELATED ARTICLES

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: