JavaScript is one of the world's most popular programming language.
Today's Post is all about JavaScript and how it works with HTML and CSS.
So, before you continue, you should have a basic understanding of the HTML and CSS.
JavaScript is a Scripting Language which is :
- A lightweight programming language.
- A programming code that can be inserted into HTML pages.
- A code that can be executed by all modern web browsers.
- A language / code which is easy to learn.
In Java Scripting Programming language basically the page which we see in browser is called "Document".
And so if we want something to be written in HTML then one can use e.g.
document.write("This is a heading");This above code will simply write
document.write("This is a paragraph");
"This is a heading"
"This is a paragraph"
JavaScripts in HTML must be inserted between tags..
JavaScripts can be put in the and in the section of
an HTML page. and in the section of
an HTML page.
The tells where the JavaScript starts and ends.
The lines between the contains the JavaScript:
More often, we want to execute code when an event occurs, like when the user clicks a button.
If we put JavaScript code inside a function, we can call that function when an event occurs.
You will learn much more about JavaScript functions and events in later.
The tells where the JavaScript starts and ends.
The lines between the contains the JavaScript:
You don't have to understand the code above. Just take it for a fact, that the browser will interpret and execute the JavaScript code between the tags.
More often, we want to execute code when an event occurs, like when the user clicks a button.
If we put JavaScript code inside a function, we can call that function when an event occurs.
You will learn much more about JavaScript functions and events in later.
On Click this text will B replaced
>Try it
Semicolon:
We generally dont need semicolon to terminate JS code(one line) if we write each JS statement in individual/One line
But If we want to write more then one JS statements then each statements must be seperated by semicolon.
like as if
without semicolon:
with semicolon:
Is case sensitive JavaScript?
Watch your capitalization closely when you write JavaScript statements:
A function "getElementById" is not the same as "getElementbyID".
A variable named "myVariable" is not the same as "MyVariable".
No comments:
Post a Comment