Lesson 6: HTML5 and Javascript

HTML5 and Javascript tutorial

Javascript and HTML5

HTML5 and Javascript

HTML5 and Javascript

HTML5 and Javascript:

In simple words Java Scripts is used to make HTML pages more dynamic and interactive(form validation, dynamic changes of content, etc.). Java Script is a scripting language which is defined inside the <script> ..</script> tag, javaScript manipulates the DOM(changing of HTML contents). which is embedded in HTML tags and is used for client-based web development. It is a dynamic, weakly-typed, prototype-based language based on functions(functions that are objects with properties themselves).

If used HTML5 and Javascript togethar we can develop more interactive webpage. HTML5 and Javascript is one the basic need if you wish to nourish your career as a UI Developer in IT industry.HTML5 and Javascript togethar is used to make menu in website, pop ups, rollover images , animations, slider etc.

For Example

Document.getElementById(“demo”).innerHTML = “Hello everyone”;

NOTE: A prototype-based language does not use classes to define object properties, but prototypes which include methods.

The <script> element can either contains scripting statements or it can point to an external script file through the src attribute.

<script>document.write(“Hello”);alert(“Hello”);</script>

or

<script src=”samplefile.js”></script>

You can also use JS to:

  • Delete HTML elements
  • Copy and Clone HTML elements
  • Change HTML elements
  • Create new HTML elements
  • many more examples are there…

 

Java Script Basic Syntax

you need to know about the syntax of Java Script most basic things:

  • document: represents the HTML document that is displayed in that window
  • Use the <script></script> tag to tell the browser you are using JavaScript
  • JavaScript command line has a semicolon ; at the end
  • // and <– –> are used for comments: <—comment here—> or //comment here
  • var: as many other languages Java Script has variables. Variables are declared with the var keyword and the value can be different type. Local and global variable can be declared, local variables are with higher priority :

Example:

HTML5 Beginners

HTML5 Beginners

JavaScript Operator

Operators like +,-, &, etc. are similar to other languages. If you about C# or C++ then you note that in Java Script you can use statements such as if, else, case, for, while & if something is missing then you can use an external library.

Lists of few operators:

  • Arithmetic operators
  • Assignment operators
  • String operators
  • Bitwise operators

 

Example:

JavaScript Functions

JS is based on functions. To define a function we need to use the function keyword, which is followed by a unique function name, a list of parameters (if any), and a statement block surrounded by curly braces.

JS functions can be redefined like ordinary variables. Also value of one function can be passed to another function.

 

JavaScript Events

JS lets you execute code when events are detected. It also allows event handler attributes, with JS code to be added with HTML elements.

Few examples of html events:

  • When user click on button
  • Change of value in input field
  • When loading of page is finished

HTML5 and Javascript togethar is used in Canvas to make interactive animations , It has became a favourite because of its browser compatibility .

You Might Also Like

16 Comments

  1. 2

Comments are closed.