HTML Css JavaScript JQuery
HTML Css JavaScript JQuery
com/karrasankar158
MS Office - Product
Type Description
1
https://github.com/karrasankar158
6. AI It is an Artificial Intelligence application
that enables automation and robotics.
What Is UI ?
➢ The user requires special skills in handling an application designs with specific
technology. Hence we provide a user friendly interface so that users can easily
interact with application. It is often known as “UI”
What Is UX ?
(a) Fluid UX
(b) Unified UX
➢ The Fluid UX enables an application to load every content on to single page. The
new details are updated page. The new details are updated without reloading
the page.
➢ The Unified UX provider same experience for application across any device i.e
from a mobile to browser.
2
https://github.com/karrasankar158
WEB DEVELOPMENT
3. Internet : It resembles a wide area network that connects computer across the
world.
4. Web :
⚫ It uses a network mechanism where client sends request and server send
response.
3
https://github.com/karrasankar158
⚫ The standards of web are maintained by W3C ( World Wide Web
Consortium )
Web Architecture
Data base server : Data base server host the data and handles the various
responsibilities which includes
a) Load Balancing
b) Performance Turning
c) High availability
d) Security etc.,
a) Load Balancing
4
https://github.com/karrasankar158
b) High Availability
c) Security etc.,
Web Server :
➢ Web server resembles both hardware and software. It satisfies the client
request by sending and receiving the data.
➢ The popular web server software's are IIS, TOMCAT, JBOSS etc.,
➢ Go to Administrative tools
➢ Go to Control panel
➢ Click OK
5
https://github.com/karrasankar158
➢ Type the following in address bar
(or)
http://127.0.0.1/amazon
Note : Make sure that yours IIS is started. If stopped, then go to IIS and click START
6. Click OK
6
https://github.com/karrasankar158
-docs - cssdemo.pdf
http://localhost/amazon/images/car.jpeg
Web Page :
1. Static Page
2. Dynamic Page
Static Page :
➢ The memory allocated for the first request the same memory will be used across
other requests.
➢ A static page contains same information to display across any no.of requests and
clients.
➢ The static pages are designed by using HTML, CSS, and Client side script.
7
https://github.com/karrasankar158
Dynamic Page :
➢ The dynamic pages are designed by using server side technologies like JSP, PHP,
ASP etc.,
Web application :
Blog : [ web-log]
Micro blog :
8
https://github.com/karrasankar158
Example : twitter
Wiki : [quick-hawain]
Podcasting :
Widgets :
Web debugger :
Api’s :
9
https://github.com/karrasankar158
Api is a service provided by third party sources which you can
integrate in to any application to provide a specific functionality.
Example : google maps api, facebook login api, captcha api etc.,
➢ URL is the virtual path generated by a web server and used by clients in order to
access the resources from a website.
➢ The URI is an identifier used to access any specific location within the resource.
URL
http://www.amazon.in/electronic.jsp#mobiles
↓ ↓ ↓
Protocol : A protocol defines a set of rules that are used by computers in network
to communicate with each other. The popular protocols are - http, https, ftp, file,
ttp/ip, msmq, named pipes, smtp etc.,
10
https://github.com/karrasankar158
HTML
&
➢ SGML - Standard Generic Markup Language are the first markup languages used
for internet.
➢ TIM BERNERS LEE introduced “HTML” as a markup language for web in early
1990’s.
i. Normal Elements
v. Foreign Elements
11
https://github.com/karrasankar158
12
https://github.com/karrasankar158
( i ) Normal Elements :
Example : <b>html</b>
( ii ) Void Elements :
Example : <img>
13
https://github.com/karrasankar158
Your text <b>HTML</b>
</textarea>
<html>
( v ) Foreign Elements :
( i ) Document Declaration
( ii ) Document Scope
Document Declaration :
➢ HTML is available in two major versions i.e HTML 4 and HTML 5, which are used
in real world development.
14
https://github.com/karrasankar158
➢ Every browser have a parsar ( translator ) that can handle both versions of HTML.
However, Parsar uses the 4 version by default.
➢ You have to define and specify about HTML 5 version by using the document
declaration.
<!DOCTYPE html>
Document scope :
➢ A Developer must define the scope of every document by using the element
<html>.
Syntax :
<!DOCTYPE html>
<html>
Document-1
</html>
<html>
Document-2
</html>
15
https://github.com/karrasankar158
1. Head
2. Body
Head Section :
➢ The contents of head section are use by browser (or) by the workspace.
<head>
a. Title
b. Link
c. Meta
d. Script
e. Style
a) Title :
It is an element defined in head section and used to display a title for page
in the browser title box.
Syntax :
<head>
</head>
16
https://github.com/karrasankar158
b) Link :
It is an element defined in head section and used to link external files like
CSS, Shortcut icon etc.,
Syntax :
<head>
</head>
❖ It is an void element.
Creating a Favicon :
1. Open MS Paint
Name : “favicon”
Type : PNG
I. Run cmd
C) Meta :
17
https://github.com/karrasankar158
➢ Meta describes the meta data i.e the information about your page.
➢ The contents of meta are required to define in a web page to make it more SEO
friendly [ search engine optimization ].
➢ Meta comprises of attributes that are used to configure your page. So that
crawlers can easily find the page.
Attributes Description
Note : The meta data options are defined by using “name” attribute and the values
are defined by using “content” attribute.
18
https://github.com/karrasankar158
Example : About.html
<!DOCTYPE html>
<html lang=”en-IN”>
<head>
<meta charset=”UTF-8”>
</head>
</html>
(d) Script : It is used to embedded client side and server side script in to a web page,
which includes Java Script, Jquery, Angular, ASP etc.,
Syntax :
<script type=”text/javascript”>
</script>
<script runat=”server”>
</script>
19
https://github.com/karrasankar158
(e) Style : It is used to embedded styles in to web page. Which makes html more
interactive and responsible.
Syntax :
<style type=”text/css”> →Script, Style these two are present in any section not stick to head section.
</style>
The body tag comprises of attributes that are used to control the
appearance of contents in body section.
Attribute Description
Right margin
Top margin
Bottom margin
Syntax :
<body background=”images/logo.png”>
20
https://github.com/karrasankar158
<body vlink=”red” alink=”green”>
Element Description
21
https://github.com/karrasankar158
span It defines a container to present in line block of code to
display side by side.
https://code.visualstudio.com
22
https://github.com/karrasankar158
➢ File Menu → Open → C:/Amazon
“VS.Code.Icons” - install
literals Description
<div>
23
https://github.com/karrasankar158
</div>
Blank space
<div>
H T M L
</div>
Pre formatted
<div>
<pre>
#include <stdio.h>
Main()
Printf(“Welcome to HTML”)
</pre>
</div>
<br/> It specifies self ending for void elements to ignore warnings from debugger.
24
https://github.com/karrasankar158
Acronymn : It is used to display screen tips. Which are shown only when mouse
pointer is over the content.
Syntax :
<div>
<br>
</div>
Headings in HTML :
➢ Headings in a Web page are defined by using the tag <hn>, Where n refers to
level number 1 to 6.
Example :
It is a Virtual Directory.
25
https://github.com/karrasankar158
Attribute :
Paragraphs :
Example :
<p align=”center”>
…your text….
</p>
BlockQuote :
Example :
<blockquote align=”justify”>
….your text……
</blockquote>
Data List :
A Data list is a collection of terms and definitions, which are displayed in a pre
defined format. The tags used for data list are,
26
https://github.com/karrasankar158
Tag Description
Example :
<dl>
<dt>Web Site</dt>
<dt>URL</dt>
</dl>
HTML provides a set of elements for displaying the contents with a summary which
you can expand (or) collapse dynamically.
➢ The <details> element is used to encapsulate any content and summary is used
to define a summary text for the content.
Example :
<body>
<h1>HTML<h1>
<details open>
<summary>Web Server</summary>
27
https://github.com/karrasankar158
It resembles hardware and software.
</details>
<details>
<summary>Web Site</summary>
It is a Virtual Directory
</details>
</body>
Ordered List:
➢ The numbering will update automatically when you add (or) delete an item.
Syntax :
<ol>
</ol>
Attribute Description
28
https://github.com/karrasankar158
type It specifies the numbering type of list them, which can
“1,a,A,I,i “
Syntax :
</ol>
Output : e. item-1
F. Item-2
</ol>
Output : 2. item-1
1. Item-2
<body>
<h2>Tutorial</h2>
29
https://github.com/karrasankar158
<ol>
<li>HTML
<ol type=”a”>
<li>Normal Elements
<ol type=”I”>
<li>Bold</li>
<li>Italic</li>
</li>
<li>Void Elements
<ol type=”I”>
<li>img</li>
<li>link</li>
</ol>
</li>
</ol>
</li>
<li>Java Script
<ol type=”a”>
<li>Variables
<ol type=”I”>
<li>var</li>
<li>let</lt>
</ol>
30
https://github.com/karrasankar158
</li>
<li>Data Types
<ol type=”I”>
<li>Number</li>
<li>String</li>
</ol>
</li>
</ol>
</li>
</ol>
</body>
<!DOCTYPE html>
<html>
<body>
<h2>Tutorial</h2>
<ol>
<li>HTML
<ol type="a">
<li>Normal Elements
<ol type="i">
<li>Bold</li>
<li>Italic</li>
</ol>
31
https://github.com/karrasankar158
<li>Void Elements
<ol type="i">
<li>Img</li>
<li>Link</li>
</ol>
</li>
</li>
</ol>
<li>Java Script
<ol type="a">
<li>Variables
<ol type="i">
<li>Var</li>
<li>Let</li>
</ol>
<li>Data Types
<ol type="i">
<li>Number</li>
<li>String</li>
</ol>
</li>
</li>
</ol>
</li>
</li>
</ol>
32
https://github.com/karrasankar158
</body>
</html>
OUTPUT
<!DOCTYPE html>
<html>
<body>
<h1>Shopping Categories</h1>
<ol>
<li>Electronics
33
https://github.com/karrasankar158
<ol type="a">
<li>Samsung TV</li>
<li>LG Mobile</li>
</ol>
<li>Shoes
<ol type="a">
<li>Nike Shoes</li>
</ol>
</li>
</li>
</ol>
OUTPUT
34
https://github.com/karrasankar158
Un ordered List :
➢ Bulleted list can define the item type in to disc, circle and square.
Syntax :
<ul type=”square”>
<li>HTML</li>
<li>Java Script</li>
</ul>
35
https://github.com/karrasankar158
<ol>
<li> HTML
<ul>
</ul>
</li>
<ul>
</ul>
</li>
</ol>
36
https://github.com/karrasankar158
The formatting of text includes changing of font, style and effects for text present in
a page.
➢ HTML provides several tags that are used for formatting text. They are,
1. <font>
attribute description
Example :
Welcome to HTML
</font>
2. Font Styles
Tag Description
37
https://github.com/karrasankar158
mode.
3. Font effects
Tag Description
Example :
5<sup>th</sup> October
H<sub>2</sub>0
38
https://github.com/karrasankar158
Images In HTML :
HTML provides options to display and handle images in a Web Page. The major type
of images supported on internet are,
➢ It can be animated.
39
https://github.com/karrasankar158
➢ Mostly used for Architecture diagrams.
The tag <img> is used to embed image into Web Page. It is a void element. Hence it
doesn’t require an end tag.
Attribute Description
src It gets the path and file name which is used to display as
image source.
Height, width It specifies the width and height of image in pixels (or) in
percent. The image size in percent will fit the image according
to browser size.
align It sets left and right align for image so that text can wrap
beside image.
Syntax :
40
https://github.com/karrasankar158
Advanced Attributes :
Attribute Description
Values : Anonymous
Use-credentials
sync
async
auto
importance It defines the priority for image so that browser loads images
according to priority.
Values :
low
medium
high
srcset It defines the set of images to display when the browser is changing
the state i.e image can change according to browser size.
41
https://github.com/karrasankar158
Google Adsense define standards for displaying images as advertisement
banners. The standard size of banners in width*height are shown below,
1. Leader board
728x90 pixels
2. Half Page
300x600 pixels
3. Large Rectangle
336x280 pixels
4.Medium Rectangle
300x200 pixels
1. A link is clickable text, picture (or) graphic that navigates the user to any named
location when clicked.
42
https://github.com/karrasankar158
4. Hyper links are classified in to two types,
➢ Intra document link specifies navigation from one location to another within the
same page.
➢ You have to configure a reference id to the elements so that you can access
from a hyper link.
Syntax :
<figure id=”tv”>
<ol id=”list”>
➢ Anchor <a> element can get and set the id into url by using the attribute href.
Syntax :
Example :
<body>
43
https://github.com/karrasankar158
<ol>
</ol>
<h2 id=”html”>HTML</h2>
<h2 id=”js”>JavaScript</h2>
</body>
➢ The target file opens in a browser only when the relative plug-ins are supported.
➢ If the plugin is not available then browser will download the target file.
Example :
<ol>
44
https://github.com/karrasankar158
<li><a href=”hrrp://www.w3.org”> W3C Official Site</a></li>
</ol>
FAQ
A) By defining “target=_blank”
A) By using
-Frames
-Iframe
45
https://github.com/karrasankar158
Syntax :
<frameset cols=”30%70%”>
</frameset>
- shopping.html
- electronics.html
- shoes.html
- leftpanel.html
2. Shopping.html [source]
<!DOCTYPE html>
<html>
<head><title>Amazon Shopping</title></head>
</frameset>
</html>
3. Leftpanel.html [source]
<div>
46
https://github.com/karrasankar158
<h2>Amazon Shopping</h2>
<ol>
</ol>
</div>
4. electronics.html [source]
<style>
.product {
border:2px;
Padding:10px;
Margin:10px;
Background-color:antiquewhite;
</style>
<div>
<h2>Electronic Products</h2>
<div class=”product”>
<figure>
47
https://github.com/karrasankar158
<figcaption>Samsung TV : ₹ 45,000/-</figcaption>
</figure>
</div>
<div class=”product”>
<figure>
</figure>
</div>
</div>
iframe :
Syntax :
Example :
48
https://github.com/karrasankar158
Index.html
<body>
<nav>
<menu>
<span>|</span>
</menu>
</nav>
</header>
<section>
</section>
</body>
3. Create a new HTML Page with iframe src as video URL changed to “embed”
49
https://github.com/karrasankar158
Example :
Tables in HTML
Element Description
<caption> It sets a caption for table, which is used in SEO to identify the table.
Example :
<body>
<div>
<table>
50
https://github.com/karrasankar158
<caption>Products List</caption>
<thead>
<th>Product Id</th>
<th>Name</th>
<th>Price</th>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Samsung TV</td>
<td>45000.66</td>
</tr>
<tr>
<td>2/td>
<td>Mobile</td>
<td>12000.44</td>
</tr>
</tbody>
<tfoot>
<tr>
<td> </td>
51
https://github.com/karrasankar158
<td> </td>
</tr>
</tfoot>
</table>
</div>
</body>
Table Attributes
Attribute Description
frame It sets a frame for table.which includes box, rhs, lhs, above, below
and void.
Syntax :
Note :
52
https://github.com/karrasankar158
Rules cannot use groups if table doesn’t have groups.
Attribute Description
cellpadding It sets space between the cell border and its content
Note :
Syntax :
Attribute Description
height It specifies the height in pixels. You can define height for table
and tr.
width It specifies width in pixels. You can define width for table, th and
td.
53
https://github.com/karrasankar158
Syntax :
<tr height=”200”>
<th width=”400”>
<td width=”400”>
Example :
“home.html”
<head><title>Home</title></head>
<body>
<tr height=”100”>
<td colspan=”3”>
<h1 align=”center”>
Online UI Tutorial</h1>
</td>
</tr>
<tr height=”300”>
<td width=”200”>
<font size=”5”>
<ol>
54
https://github.com/karrasankar158
<li><a href=”html.html” target=”frameBody”>HTML</a></li>
</ol>
</font>
</td>
<td width=”700”>
</td>
<td width=”100”>
</td>
</tr>
<tr height=”100”>
<td colspan=”3”>
<div align=”center”>
</div>
</td>
</tr>
</table>
</body>
55
https://github.com/karrasankar158
Attribute Description
Syntax :
<table align=”center”>
<tr align=”center”>
<td align=”right”>
5. Table Background :
Attribute Description
background It sets a background image for table, group, row (or) cell.
Syntax :
<table bgcolor=”yellow”>
<thead bgcolor=”yellow”>
<table background=”../images/logo.png”>
56
https://github.com/karrasankar158
Attribute Description
Example :
<body>
<thead>
<tr>
</tr>
<tr>
<th colspan=”2”>Name</th>
<th colspan=”3”>Address</th>
</tr>
<tr>
<td>First Name</td>
<td>Last Name</td>
<td>City</td>
<td>State</td>
<td>Postal code</td>
57
https://github.com/karrasankar158
</tr>
</thead>
<tbody>
<tr>
</tr>
<tr>
<td>Raj</td>
<td>Kumar</td>
<td>Chennai</td>
<td>TN</td>
<td>600076</td>
</tr>
<tr>
<td>Raj</td>
<td>Kumar</td>
<td>Chennai</td>
<td>TN</td>
<td>600076</td>
</tr>
</tbody>
<tfoot>
<tr>
58
https://github.com/karrasankar158
<td rowsapn=”2” align=”center”>Footer Section</td>
</tr>
<tr>
</tr>
</tfoot>
</table>
</body>
Example :
Nested Table
<body>
<caption>Products Catalog</caption>
<tr align=”center”>
<td>
</td>
<td>
<tr>
59
https://github.com/karrasankar158
<td>Name</td>
<td>Samsung TV</td>
</tr>
<tr>
<td>Price</td>
<td>56000.66</td>
</tr>
</table>
</td>
</tr>
<tr align=”center”>
<td>
</td>
<td>
<tr>
<td>Name</td>
<td>Nike casuals</td>
</tr>
<tr>
<td>Price</td>
60
https://github.com/karrasankar158
<td>4200.55</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
Forms in HTML
Form provides an UI that allows the user to interact with the data I.e input,
view, edit, delete etc.,
<input>
<select>
<datalist>
<option>
<optgroup>
<meter>
61
https://github.com/karrasankar158
<progress>
<textarea>
It is a container that encapsulates the set of elements and submit their to specified
server side source.
Attribute Description
action It specifies the target location where the form data need to be
submitted.
target It specifies the action target which can submit with in the same
window (or) a new window.
Syntax :
….…………………………………..form elements………………………………………
</form>
62
https://github.com/karrasankar158
GET POST
1. Data will be arranged in HTTP header by Data will be arranged in HTTP message
appending to the URL as query string. body [ form body ].
2. Data is in query string so user can view the Not visible to user.
data.
3. Less secured compared to POST method Bit safer than GET method because data is
because data is in query string so it will be saved saved in history (or) web server logs.
in browser history and webserver logs.
4. As data is saved in URL so its saves only 2048 Can be used for any amount of data.
chars.
7. Only ASCII character data type allowed. No restriction. Allows binary data also.
A <fieldset> sets a frame for group of elements in a form and a <legend> will set a
caption for frame.
Syntax :
<fieldset>
…………..form elements……………
</fieldset>
63
https://github.com/karrasankar158
The <input> Element :
It is a form element that allows to input any value from the UI. It can handle various
types of values for different type of situations. The commonly used attributes are,
2. name : it specifies a name for input element so that form can submit its value to
server. If name not defined then form cannot submit its value.
3. class : it defines a CSS class to input element so that you can customize its
appearance.
4. value : It defines the default value to be used while submitting the form.
5. type : it specifies the data type to allow in the input field. HTML-5 introduced
several new data types which can restrict the input value it includes text, password,
number, date, year, month, file, range, color, url, email etc.,
Syntax :
64
https://github.com/karrasankar158
Note : The new input types of HTML 5 are browser dependent. Hence will not have
the same behaviour across browsers.
Syntax :
8. Min
9. Max these are the attributes used to define min and max numeric range
constraints in a number input.
Syntax :
10. placeholder : it defines the water mark text to display for input field when
there is no value defined.
Syntax :
11. autofocus : it sets a focus to any input element in a form so that user can start
input immediately after loading the form.
Syntax :
12. size : it is used to set width for text box the default width is ‘20’.
Syntax :
65
https://github.com/karrasankar158
<input size=”3” type=”text” name=”txtCvv”>
13. required : it is used to define mandatory fields in a form so that form will not
submit until the field is defined with a value.
Syntax :
14. pattern :
➢ The regular expressions are built by using meta characters and quantifiers.
\^ Starts with
$ Ends with
66
https://github.com/karrasankar158
[a-z] Only lower case allowed.
Quantifier Description
Syntax :
67
https://github.com/karrasankar158
15. list : it is a new HTML property used to define a data list of any input element.
So that the options of data list will be displayed during input.
Syntax :
<div>
<datalist id=”terms”>
<option>HTML Tutorial</option>
<option>Java tutorial</option>
<option>HTML Examples</option>
</datalist>
</div>
Radio Buttons :
➢ The radio buttons are form elements that allow the user to select one (or)
multiple options from a group of choices.
➢ Radio’s once checked cannot be unchecked. Hence radio’s must be used with
MUTEX mechanism [ Mutual Exclusion ].
➢ To define MUTEX all radio’s in a group must be defined with same name.
➢ If MUTEX is defined for radio’s then it will allow the user to select any one
option from a group of choices.
Attributes -
1. id
2. name
68
https://github.com/karrasankar158
3. class
4. checked
5. value
Note : The radio’s submit the value ON when the value is not defined.
Syntax :
Example :
<body>
<form>
<fieldset>
<legend>Choose Gender</legend>
<br>
<button>Submit</button>
</fieldset>
</form>
</body>
Check Box :
➢ A check box is same like a radio button which allows to select one (or) multiple
options but it can check (or) uncheck the option without MUTEX.
Properties :
69
https://github.com/karrasankar158
1. Is
2. Name
3. Class
4. Value
5. Checked
Syntax :
Example :
<body>
<form>
<fieldset>
<br>
<button>Submit</button>
</fieldset>
</form>
</body>
➢ A drop down list provides an UI from where it will allow the user to select only
one option from a group of choices.
70
https://github.com/karrasankar158
Element Description
<optgroup> It groups a list of options under one category and defines a group
name.
Example :
<body>
<form>
<fieldset>
<legend>Select a Product</legend>
<select name=”lstproducts”>
<optgroup lable=”Electronics”>
</optgroup>
71
https://github.com/karrasankar158
<optgroup lable=”shoes”>
</optgroup>
</select>
<button>Submit</button>
</fieldset>
</form>
</body>
List Box :
➢ A list box is similar to a dropdown in elements used to designed the UI i.e it uses
<select>
<option>
<optgroup>
➢ You can transform the behaviour to list box by defining the attributes
A. size
B. multiple
Example :
<fieldset>
<legend>Select City</legend>
72
https://github.com/karrasankar158
<option>Delhi</option>
<option>Hyd</option>
<option>Chennai</option>
</select>
</fieldset>
Text area :
Syntax :
</textarea>
Syntax :
Terms of Service
</textarea>
Meter Control :
➢ It is a new HTML control used to display grade meter with various effects.
73
https://github.com/karrasankar158
Property/attribute Description
Syntax :
Example :
<body>
<fieldset>
<legend>Ratings Meter</legend>
<dl>
<dt>Normal Meter</dt>
<dd>
<meter></meter>
</dd>
<dt>Good 100%</dt>
<dd>
</dd>
<dt>Good 40%</dt>
74
https://github.com/karrasankar158
<dd>
</dd>
<dt>Average</dt>
<dd>
</dd>
<dt>Poor</dt>
<dd>
</dd>
</dl>
</fieldset>
</body>
Progress Control :
➢ It allows partial post back i.e only a portion of page is posted to server.
➢ Progress control can show the status of any task performed within the page. It
includes downloading, uploading, copying, installing etc.,
Syntax :
75
https://github.com/karrasankar158
Example :
<body>
<fieldset>
<legend>Downloading File</legend>
<dl>
<dd>
<progress></progress>
</dd>
<dt>10% Downloaded</dt>
<dd>
</dd>
<dt>80% Downloaded</dt>
<dd>
</dd>
<dt>Download Completed</dt>
<dd>
</dd>
</dl>
</fieldset>
76
https://github.com/karrasankar158
</body>
1. Marquee : It is used to define scrolling and sliding contents in a page. You can
optionally control the scrolling and sliding animation by using following attributes,
Attribute Description
Syntax :
….………………..your content………………..
</marquee>
<marquee behaviour=”alternate”>
….……………your content……………
</marquee>
77
https://github.com/karrasankar158
Flash
➢ It provides publishing features for web so that you can create and publish
animations for web.
➢ It also supports java script to define queries for animation and make it dynamic.
Flash Workspace :
1. Tool Bar
2. Stage
3. Timeline
A) Layers
B) Frames
4. Library
78
https://github.com/karrasankar158
Title : Leaderboard
Description : any..
Width : 728 px
Height : 90 px
Frame/sec : 24
Tool Description
79
https://github.com/karrasankar158
Rectangle Rectangle
Animations in Flash
1. Frame by Frame
2. Tweening
80
https://github.com/karrasankar158
Tweening Animation :
In tweening animation you have to define the key frames at random positions from
begin to end.
Flash will create the frames with animation between the start and end points.
1. Motion tween
2. Shape tween
Motion tween :
In motion tween you can change the position, size and orientation of any object.
Example :
6. Similarly insert keyframe at 20, 30 & 40 and change position (or) size of oval at
every key frame.
8. Right click on frames and choose the option “Create Motion Tween”.
A motion guide allows you to define your own path for moving an object.
Example :
81
https://github.com/karrasankar158
1. Add a new text layer and insert text.
2. Insert key frame at 50 and choose motion tween.[ right click …. create motion
tween ]
5. Add a circle in guide layer, remove fill color, break the circle at any position using
eraser.
6. Keep
Mask Effect :
“Car”
Width : 550
Height : 400
82
https://github.com/karrasankar158
X : 0.0
Y : 0.0
“Mask”
Flash Symbols :
A symbol is used for creating reusable objects which you can import and use in any
scene.
Example :
3. Insert any object and animate with Frame by Frame (or) tweening
Scenes in Animation
83
https://github.com/karrasankar158
1. A movie comprises of collection of scenes that are displayed in a sequence and
executed one after another.
Example :
Shape tween :
Example :
“diwali.fla”
84
https://github.com/karrasankar158
3. Save in your website physical path
“diwali.swf”
“index.html”
<div align=”center”>
</div>
Styles in HTML
Styles are set of attributes defined for HTML elements to make the
presentation more interactive and responsive.
1. Inline
2. Embed
Inline :
85
https://github.com/karrasankar158
In this method the styles are defined for every element individually by using a
style attribute. These effects are not accessible to other elements.
Syntax :
<body>
</body>
Embed :
In this method the styles are defined in page by using a <style> element, so that
the styles are accessible to any element in page.
Syntax :
<head>
<style>
h2 {
Background-color:red;
Color:white;
Text-align:center;
<style>
</head>
<body>
<h2>HTML</h2>
86
https://github.com/karrasankar158
<h2>CSS</h2>
<h2>JavaScript</h2>
</body>
In this method the styles are maintained in a separate style sheet as external
file, so that you can access the styles and use in any page. However, using an
external file will increase the number of requests to a page and the load time.
Syntax :
Effects.css
h2 {
Background-color:red;
Color:white;
Text-align:center;
<head>
<body>
<h2>HTML</h2>
<h2>CSS</h2>
<h2>JavaScript</h2>
</body>
87
https://github.com/karrasankar158
Minification
Minification is a technique used for CSS and JavaScript files to reduce their size.
Minification will remove the blank spaces, line breaks and will use all possible
shortcuts to reduce the file size.
1. Smalify
2. CSS minifier
3. js minifier
4. ajax minifier
Note :
Always use the minified files in production and the uncompressed files in
development because minified files cannot track the error location if any exception
occurred.
The CSS files are maintained in a separate repository server and can be accessed
and used in any project remotely this mechanism is known as CDN.
Example :
Style Syntax
88
https://github.com/karrasankar158
1. Inline Style Syntax : In this method the style attributes and values are
applied to any element by using “style” attribute.
2. Embedded (or) CSS : In this method the styles are applied to elements
based on the selectors.
<style>
Selector
attributeName:value;
attributeName:Value;
</style>
1. Type selector
2. ID Selector
3. Class Selector
4. Attribute Selector
5. Decendent/Child Selector
Type Selector : It directly specifies the tag name to which the given effects are
applied. In this method whenever same tag is added in to page it is applied with the
effects. You cannot ignore for any specific element.
Example :
89
https://github.com/karrasankar158
<style>
h2, p {
Text-align:center;
Color:red;
</style>
Example :
<style>
#effects {
Text-align:center;
Color:red;
</style>
<body>
</body>
Class Selector : It is defined by using “.” and can be accessed by using the attribute
class. It allows multiple classes for any single element.
90
https://github.com/karrasankar158
Example :
<style>
.backEffects {
Background-color:red;
.textEffects {
Text-align:center;
Color:red;
</style>
<body>
</body>
Example :
<style>
Input[type=”text”]{
Text-align:center;
Background-color:red;
91
https://github.com/karrasankar158
</style>
<body>
<form>
</form>
</body>
Decendent Selector : It is used to apply effects based on the child element under
specific parent element. It is mostly used when same type of child element is
available for different HTML elements.
Example :
<style>
ol > li {
Color:red;
</style>
<body>
<ol>
<li>item-1</li>
<li>item-2</li>
</ol>
</body>
92
https://github.com/karrasankar158
Meta Characters in Selectors :
Character Description
Example :
<style>
Input[class^=”effects”]{
Color:red;
Input[class$=”effects”]{
Color:green;
</style>
<body>
</body>
93
https://github.com/karrasankar158
Pseudo Selectors : the pseudo selectors are used to change the appearance of
existing elements by using a pseudo name. They are defined by using “:” along with
element name (or) class name.
Note : Effects can be background, border, colour (or) any other related to
appearance.
Example :
<head>
<style>
a:link {
Color: black;
a:visited {
Color:black;
</style>
</head>
<body>
<a href=”../about.html”>Home</a>
<span>|</span>
</body>
94
https://github.com/karrasankar158
3. :hover - It specifies the actions to perform and effects to apply and then the
mouse pointer is over any element.
Syntax :
element : hover {
Example :
<head>
<style>
Img {
width: 100px;
height: 100px;
img:hover {
Width: 300px;
Height: 300px;
button {
background-color: lightyellow;
button:hover: yellow;
</style>
</head>
95
https://github.com/karrasankar158
<body>
<img src=”../images/tv.jpg”>
<h2>Button Hover</h2>
<button>Submit</button>
</body>
5. :active {} - It defines effects when user hold down the mouse button on any
element.
Example :
<head>
<style>
input[type=”text”]:focus {
button:focus {
background-color: yellow;
img:active {
</style>
96
https://github.com/karrasankar158
</head>
<body>
<div>
</div>
<div>
<form>
Name:
<input type=”text”>
<button>Submit</button>
</form>
</div>
</body>
6. :enable
7. :disable
8. :readonly
These are the selectors used to verify the state of any element and
apply effects. The state indicates enabled, disabled (or) readonly.
Example :
<head>
<style>
button:enabled{
97
https://github.com/karrasankar158
cursor:grab;
button:disabled{
cursor: not-allowed;
input[type=”text”]:disabled{
background-color: darkgrey;
input[type=”text”]:read-only{
background-color: red;
</style>
</head>
<form>
Name:
<button disabled>Submit</button>
</form>
</body>
Example:
98
https://github.com/karrasankar158
<head>
<style>
input[type=”checkbox”]~span {
color:red;
input[type=”checkbox”]:checked~span {
color:green;
</style>
</head>
<body>
<fieldset>
….….conditions……….
</textarea>
<div>
<input type=”checkbox”>
</div>
</fieldset>
</body>
99
https://github.com/karrasankar158
10. :required
11. :valid
12. :invalid
These are the selectors used to define the effects for HTML elements
based on the various validation states like required, valid and invalid.
Example :
<head>
<style>
input[type=”email”]:required{
input[type=”text”]:valid{
</style>
</head>
<body>
<form>
Name:
<br>
Email:
100
https://github.com/karrasankar158
<input type=”email” required>
</form>
</body>
13. :optional - It is used to define effects for optional fields. Any field is identified
as optional if required not defined.
Example :
<head>
<style>
input[type=”email”]:optional{
input[type=”email”]:required{
</style>
</head>
<body>
<form>
</form>
</body>
101
https://github.com/karrasankar158
14. :in-range
15. :out-of-range
These are the selectors used to verify the numeric range of input value
and change the effects based on value in-range (or) out-of-range.
Example :
<head>
<style>
input[type=”number”]:in-range {
input[type=”number”]:out-of-range {
</style>
</head>
<body>
<form>
Age :
</form>
</body>
102
https://github.com/karrasankar158
16. :target - It is a selector used for applying effects for any element that becomes a
target in the page. The element must be defined with an “id” and the id’s are
referred from URL using “#”.
Example :
<head>
<style>
.section {
margin:10px;
padding: 10px;
.section:target {
background-color: green;
color:white;
</style>
</head>
<body>
<header>
<a href=”#html”>HTML</a>
<span>|</span>
<a href=”#css”>CSS</a>
<span>|</span>
<a href=”#js”>JavaScript</a>
103
https://github.com/karrasankar158
</header>
HTML Tutorial
</div>
CSS Tutorial
</div>
JavaScript Tutorial
</div>
</section>
</body>
CSS provides a set of selectors that are used to apply effects to the elements
based on their occurance i.e the level number in a hierarchy. They are,
1. :first-of-type
2. :last-of-type
3. :only-of-type
104
https://github.com/karrasankar158
4. :only-child
5. :nth-child()
6. :nth-last-child()
7. :nth-of-type()
8. :nth-last-of-type()
9. :last-child
10. :root
11. :empty
:first-of-type ]
:last-of-type ]
These are the selectors used to apply effects for any element when it is at
the first and last occurance in a list.
Example :
<head>
<style>
tr:first-of-type {
background-color: darkmagneta;
color:white;
tr:last-of-type {
background-color: teal;
color: white;
105
https://github.com/karrasankar158
}
</style>
</head>
<body>
<div>
<tr>
<td>Name</td>
<td>Prcie</td>
</tr>
<tr>
<td>Samsung Tv</td>
<td>120000</td>
</tr>
<tr>
<td>Mobile</td>
<td>14000</td>
</tr>
</tr>
</table>
</div>
</body>
106
https://github.com/karrasankar158
CSS Effects
background Effects :
1. background-color
2. background-image
3. background-position
4. background-size
5. background-repeat
6. background-origin
7. background-clip
8. background-attachment
Effect Options
- x:pixels y:pixels
107
https://github.com/karrasankar158
background-repeat Repeats background
- repeat
- no-repeat
- repeat-x
- repeat-y
- border-box
- content-box
- border-box
- content-box
- padding-box
Example :
<head>
<style>
.effects{
background-repeat: no-repeat;
background-clip: content-box;
padding: 20px;
108
https://github.com/karrasankar158
}
</style>
Example :
<style>
body {
background-position:center center;
background-repeat:no-repeat;
background-attachment: fixed;
background-size: 30%;
</style>
CSS Borders
1. border-style
2. border-color
3. border-width
4. border-left
5. border-right
6. border-top
7. border-bottom
109
https://github.com/karrasankar158
Example :
<head>
<style>
.effects {
border-top-color: red;
border-left-color: red;
border-left-style: double;
border-top-style: double;
border-top-width: 5px;
border-left-width: 5px;
border-right-width: 8px;
border-right-color: green;
border-bottom-color: green;
border-right-style: dotted;
border-bottom-style: dotted;
</style>
110
https://github.com/karrasankar158
<style>
P{
CSS Margins
1. margin
2. margin-left
3. margin-top
4. margin-bottom
Example : Shorthand
<style>
p{
Margin: 100px
</style>
111
https://github.com/karrasankar158
Example : individual Margins
<style>
P{
margin-left: 100px;
margin-top: 20px;
</style>
CSS Padding
Padding defines the distance between border and the content. You can configure in
pixels (or) in percent. They are,
padding
padding-left
padding-right
padding-top
padding-bottom
Example :
<style>
P{
padding-left: 20px;
padding-right: 20px;
112
https://github.com/karrasankar158
padding-top: 30px;
padding-bottom: 30px;
</style>
<body>
</body>
CSS provides a set of properties define the dimensions for adjusting height and width
of any element. The properties are,
height
max-height
max-width
min-height
min-width
width
The attributes min and max are used to define that the content width and height will
not be responsive and they remain with fixed height and width.
113
https://github.com/karrasankar158
Example :
<style>
p{
width: 400px;
height: 100px;
min-width:300px;
min-height: 75px;
</style>
<body>
</body>
CSS provides a set of attributes that are used to control the behaviour of text in a
page. It includes the following,
color
direction
letter-spacing
line-height
text-align
text-decoration
114
https://github.com/karrasankar158
text-indent
text-shadow
text-transform
text-overflow
unicode-bidi
vertical-align
white-space
word-spacing
Example :
<body>
<dl>
<dt>Color</dt>
<dt>Direction</dt>
<dt>Letter/Word Spacing</dt>
<dt>Text Decoration</dt>
<dt>Text Shadow</dt>
<dt>Text Transform</dt>
115
https://github.com/karrasankar158
<dt>Text Indent</dt>
<dd>
Your text
</div>
</dl>
CSS Fonts
CSS provides several font options that are used to change the character
appearance with font face, size, style etc., The attributes are,
font
font-family
font-size
font-style
font-variant
font-weight
Example :
<style>
p{
116
https://github.com/karrasankar158
font-family: ‘courier new’, courier, monospace;
font-size: 3em;
font-style: italic;
font-weight: bold;
font-variant: small-caps;
</style>
<body>
</body>
CSS List
CSS provides a set of attributes that are used to control the ordered and
unordered list by using the following attributes,
list-style
list-style-image
list-style-position
list-style-type
Example :
<style>
ul {
list-style-image: url(‘../images/star.png);
list-style-position: outside;
117
https://github.com/karrasankar158
}
</style>
CSS Position
CSS provides a set of positions that are used to change the placement of
an object and control the behaviour. The position properties are,
Property Description
position:bottom It sets the bottom margin for specified content. It will position
at the bottom of the box.
position:fixed It sets the position fixed based on left right margins. It can
allow the scrolling of the parent content but will fix at initial
position.
position:sticky It keeps the initial position and the final position different. It
becomes sticky when it reaches the final position.
Example :
<head>
118
https://github.com/karrasankar158
<style>
article {
bottom: 0px;
right: 0px;
width: 300px;
height: 50px;
background-color: yellow;
position: fixed;
.toolbar {
background-color:green;
color: white;
text-align: center;
position: sticky;
top: 0px;
margin-top: 100px;
</style>
</head>
<body>
<article>
Results Released..
119
https://github.com/karrasankar158
</article>
<div class=”toolbar”>
<a>Home</a>
<span>|</span>
<a>About</a>
<span>|</span>
<a>Contact</a>
</div>
<div>
</div>
</body>
BootStrap
Booststarp is one of the worlds largest repository of HTML, CSS and JavaScript.
Installing BoostStrap :
https://nodejs.org/en/download/
120
https://github.com/karrasankar158
- Download and install “.msi” file for windows.
C:\> node -v
C:\> npm -v
Node_modules
-bootstrap
-dist
-CSS
-bootstrap.css
Bootstrap.min.css
Note : you can also install bootstrap in package managers like Yarn, Composer,
Ruby Gems, NuGet etc.,
- Go to Extensions
- Search for
Publisher : Zignd
121
https://github.com/karrasankar158
- install for VS Code
“demo.html”
<head>
<link rel=”stylesheet”
href=”../node_modules/bootstrap/dist/css/bootstrap.css”>
</head>
<div class=”container”>
Welcome to Bootstrap
</div>
</div>
BootStrap Alerts
Class Name
alert
alert-primary ]
alert-secondary ]
122
https://github.com/karrasankar158
alert-success ]
alert-danger ]
alert-info ]
alert-dark ]
alert-light ]
Example :
<h2 class=”alert-heading”>info</h2>
<div>
</a>
</div>
</div>
BootStrap Badge
It is a CSS effect used for highlighting any specific character (or) symbol within the
context of existing content. The classes are,
123
https://github.com/karrasankar158
ClassName
badge-primary]
badge-secondary]
badge-Info]
badge-light]
badge-success]
Example :
<div class=”container”>
</div>
<div>
HTML Examples
</div>
<div>
JavaScript Tutorial
124
https://github.com/karrasankar158
</div>
<div>
CSS Templates
</div>
</div>
</body>
BootStrap Buttons
BootStrap provides a set of classes that are used to define appearance for
buttons and control their behaviour to make responsive. The classes are,
btn-sm ] button si
btn-block ] responsive
btn-link ] button as h
btn-group-vertical ]
btn-group-vertical-lg ]
btn-group-horizontal ]
125
https://github.com/karrasankar158
btn-group-horizontal-sm ] groups horizontal
btn-group-horizontal-lg ]
btn-primary ]
btn-danger ]
Example :
<div class=”container”>
<dl>
<dt>Button Colors</dt>
<dd>
</dd>
<dt>Button Responsive</dt>
126
https://github.com/karrasankar158
<dd>
</dd>
<dt>Button Outline</dt>
<dd>
</dd>
<dd>
<div class=”btn-group”>
</div>
</dd>
<dd>
</div>
</dd>
<dd>
127
https://github.com/karrasankar158
<div class=”btn-toolbar bg-primary justify-content-between”><div
class=”btn-group”><a href=”../home.html” class=”btn btn-primary”>Home</a>
</div>
<div class=”btn-group”>
</div>
</div>
</dd>
</dl>
</div>
BootStrap Card
Example :
<head>
<style>
Img {
Height:200px;
Width:150px;
128
https://github.com/karrasankar158
}
</style>
</head>
<body>
<div class=”container”>
<div class=”card-deck”>
<div class=”card”>
<div class=”card-header”>
<h2 class=”card-title”>Bose Speakers</h2>
</div>
</div>
<div class=”card-footer”>
<h2>₹ 4,600/-</h2>
</div>
</div>
</div>
129
https://github.com/karrasankar158
BootStrap Dropdown
BootStrap provides a set of classes that are used to design a dropdown menu.
It is a static dropdown menu used to display a list of items in the format of links,
buttons and images.
The classes that are used to design bootstrap dropdown menu are,
Class Description
Example :
“home.html”
<head>
<link….bootstrap.css>
<script src=”../node_modules/jquery/dist/jquery.js”></script>
<script src=”../node_modules/bootstrap/dist/js/bootstrap.bundle.js”>
</script>
</head>
130
https://github.com/karrasankar158
<body>
<div class=”container”>
<h2>BootStrap Dropdown</h2>
<div class=”dropdown”>
<div class=”dropdown-menu”>
<div class=”dropdown-item”>
<a href=”#”>
>span class=”dropdown-item-text”>Home</span></a></div>
<div class=”dropdown-divider”></div>
</div>
</div>
</div>
</div>
</body>
BootStrap Forms
BootStrap provides set of classes that are used to appearance of forms and its
elements. The classes are,
131
https://github.com/karrasankar158
Class Description
www.getBootstrap.com
2. Go to examples category
“login.html”
<head>
</head>
<body>
<div class=”container”>
132
https://github.com/karrasankar158
<div class=”btn-toolbar bg-primary text-white justify-content-between”>
<div class=”btn-group”>
</div>
<div class=”btn-group”>
<div class=”form-row”>
<form class=”form-inline”>
</form>
</div>
</div>
</div>
<div class=”form-group”>
<div>
</div>
133
https://github.com/karrasankar158
</div>
<div class=”form-group”>
<label for=”txtPwd”>Password</label>
<div>
</div>
</div>
<div class=”form-group”>
<div>
<option>Delhi</option>
<option>Hyd</option>
</select>
</div>
</div>
</div>
</form>
</div>
</body>
134
https://github.com/karrasankar158
Input group :
The BootStrap input group provides a set of classes that are used to arrange
contents in line with prefix and suffix. The classes are,
Class Description
Example :
<head>
<!…link bootstrap.css>
</head>
<body>
<div class=”container”>
<h2>Input group</h2>
<dl>
<dd>
135
https://github.com/karrasankar158
<div class=”input-group-append”>
<span class=”input-group-text”>@gmail.com</span>
</div>
</div>
</dd>
<dt>Input Prepend</dt>
<dd>
<div class=”input-group-prepend”>
<span class=”input-group-text”>₹</span>
</div>
<div class=”input-group-append”>
<span class=”input-group-text”>.00</span>
</div>
</div>
</dd>
</dl>
</div>
</body>
A list group comprises of list of items which can be organized horizontally and
vertically as a tool bar. The classes are,
136
https://github.com/karrasankar158
className
list-group
list-group-horizontal
list-group-item
list-group-item-primary,
success, warning
Example :
<li class=”list-group-item”>
</li>
<li class=”list-group-item”>
</li>
<li class=”list-group-item”>
</ul>
Note : you can add “active, disabled” options for “list-group-item” to display active
(or) disabled state.
Syntax :
137
https://github.com/karrasankar158
<li class=”list-group-item active”></li>
The Nav Bars are used for designing navigation area in a web page. It comprises
of a navigation bar with collection of items arranged in horizontal (or) vertical
orientation. The classes are,
ClassName
.nav
.nav-pills
.nav-item
.nav-link
.nav-tabs
Example :
<nav>
<li class=”nav-item”>
</li>
138
https://github.com/karrasankar158
</ul>
</nav>
1. CSS 3 and 4 versions introduced several transition effects that are used to handle
animations in web based applications.
2. The transitions have browser compatibility issues. Hence, we have to write for
various browsers the plugins used for different browsers are shown below.
➢ -ms-transform:rotate(30deg);/* IE 9 */
➢ -moz-transform:rotate(30deg);/* FireFox*/
➢ -webkit-transform:rotate(30deg);/* Safari */
➢ -o-transform:rotate(30deg);/* Opera*/
CSS Transform : The transform provides a set of methods that are used to move,
scale, spin, stretch and turn elements. The transforms can be defined by using 3
attributes,
1. transform
2. transform-origin
3. transform-style
transform : Transform is used to apply methods which can handle the following
functionalities,
⚫ translate()
⚫ rotate()
⚫ scale()
139
https://github.com/karrasankar158
⚫ skew()
⚫ matrix()
transform() : It is a transform method is used to move any object along x and y axis.
You can define in 3 ways,
a. translate()
b. translateX()
c. translateY()
Syntax :
transform:translate(x.y);
transform:translateX(pixels);
transform:translateY(pixels);
Example :
<head>
<style>
img {
width:100px;
height:100px;
transition:1s;
img:hover {
transform:transform(100px,100px);
transition:2s;
140
https://github.com/karrasankar158
}
</style>
</head>
<body>
<imd src=”../images/3.jpg”>
</body>
rotate() : It is a method used to rotate an object by specified angle. You can define
by using the units “deg”.
Syntax :
transform:rotate(360deg);
scale() : It is used to change the width and height of any image along x and y axis.
You can define the following,
A. scale(x.y)
B. scaleX(2)
C. scaleY(2) //1=100%
Syntax :
transform:scale(2,2)
transform:scaleX(2)
skew() : It is a method used for tilting the image by specified degrees along X and Y
axis. The methods are,
a) skew()
141
https://github.com/karrasankar158
b) skewX()
c) skewY()
Syntax :
transform:skew(20deg, 30deg);
transform:skew(20deg);
<head>
<style>
img {
width:100px;
height:100px;
transition:1s;
img:hover {
transform:scale(2,2);
transition:2s;
</style>
</head>
<body>
<div>
<img src="../images/tv.jpg">
142
https://github.com/karrasankar158
<marqueeonmouseover="this.stop()" onmouseout="this.start()" scrollamount="10">
<img src="../images/shoe.jpg">
<img src="../images/shoe1.jpg">
</marquee>
</div>
</body>
JavaScript
HTML - W3.org
JavaScript - MDN
143
https://github.com/karrasankar158
➢ Client side interactions.
➢ Accuracy in Animations.
➢ Parsing.
➢ Data manipulations.
Evolution of JavaScript
➢ Later, “Brendan Eich” developed a script called MOCHA, which was later
changed to “Live Script” and then “JavaScript”.
➢ However a library cannot control the application flow. Better use a Framework.
Web application
144
https://github.com/karrasankar158
(Jquery- Library)
Library is Passive
WEB APPLICATION
(Framework-AngularJS)
145
https://github.com/karrasankar158
Client Requests from Browser
Framework is Active
➢ JavaScript is used with HTML to make the static DOM in to dynamic DOM.
146
https://github.com/karrasankar158
1. Inline
2. Embed
3. External file
Inline : In this technique the JavaScript functions are defined within an element
on specific event. These functions are not accessible to other elements.
Example :
<body>
</body>
Embed : In this technique JavaScript functions are defined within the page by
using script element. So, that they are accessible to any element in page.
Syntax :
<script>
function PrintPage() {
window.print();
147
https://github.com/karrasankar158
</script>
Location of Script :
The script element in a page can be defined at <head> section (or) <body>section.
Script’s in head section are recommended when you want to execute on specific
event and explicit calling.
Script’s in <body> section are recommended when we want to execute the functions
automatically on page load.
Syntax :
<head>
<script>
</script>
</head>
<body>
<script>
</script>
</body>
2. MIME type specifies the script type whether client side (or) server side.
148
https://github.com/karrasankar158
3. You can define the type attribute (or) the language attribute for specifying MIME
type.
Syntax :
<script type=”text/javascript”>
</script>
(or)
<script language=”javascript”>
</script>
1. JavaScript functions can be written without strict mode, which allows the
developers to implement all possible shortcuts.
“use strict”
Example :
<script>
“use strict”;
function f1(){
document.write(“x=” + x);
f1();
149
https://github.com/karrasankar158
</script>
Note : If strict mode is removed, then above program executes without errors.
1. JavaScript functions can run on legacy browsers [ old version ] when defined in
HTML comments.
Syntax :
<script>
<!--
alert(“Welcome”);
-->
</script>
External File :
JavaScript functions can be maintained in a separate script file that have the
extension.js, so that the functions are accessible to many pages. However, it will
increase the number of requests and page load time.
Example :
“Scripts”
“Print.js”
150
https://github.com/karrasankar158
“use strict”;
function PrintPage() {
window.print();
<head>
<script src=”Scripts/print.js”></script>
</head>
Example :
<head>
<script>
function bodyload() {
window.document.images[0].src="../images/tv.jpg";
window.document.forms[0].elements[0].value="Login";
window.document.forms[1].elements[1].value="Register";
151
https://github.com/karrasankar158
</script>
</head>
<body onload="bodyload()">
<div>
</div>
<div>
<h2>Login</h2>
</form>
</div>
<h2>Register</h2>
Email :
</form>
</div>
</body>
152
https://github.com/karrasankar158
name. However, you cannot access any child element directly. You have to follow
the parent - child hierarchy.
Example :
<head>
<script>
function bodyload(){
pic.src="../images/shoes.jpg";
frmLogin.btnLogin.value="Login";
frmRegister.btnRegister.value="Register";
</script>
</head>
3. Refer by using ID :
Every element in HTML can be defined with a unique reference ID. You can
access the element directly by using ID without any parent-child hierarchy.
However, ID can be used by CSS and Server Side Scripting. Hence, you cannot use ID
for referring multiple elements.
“document.getElementById()”
Example :
<script>
function bodyload() {
document.getElementById("pic").src="../images/tv.jpg";
153
https://github.com/karrasankar158
document.getElementById("btnLogin").value="Login";
document.getElementById("btnRegister").value="Register";
</script>
HTML elements are presented by using a specific tag. You can access all elements
that are designed by using the given tag. JavaScript provides the function,
“document.getElementsByTagName()”
Example :
<script>
function bodyload(){
</script>
HTML elements can use class attributes for reference. Every element can
be defined with multiple references by giving the class attribute. You can access the
elements by using
“document.getElementsByClassName()”
Example :
<head>
154
https://github.com/karrasankar158
<style>
.frm {
height: 200px;
width:400px;
</style>
<script>
function bodyload() {
</script>
</head>
<body onload="bodyload()">
<form class="frm">
.......
</form>
</body>
HTML supports a Common Name for a set of elements. You can access all of
them by using the function
“document.getElementsByName()”
155
https://github.com/karrasankar158
Example :
<head>
<script>
function bodyload(){
</script>
</head>
<body onload="bodyload()">
<fieldset>
<legend>Payment Mode</legend>
</fieldset>
</body>
It is responsible for taking Input from user, processing the input and generating an
output. The various output functions and properties used in JavaScript are,
1. alert()
2. confirm()
156
https://github.com/karrasankar158
3. console.log()
console.info()
console.debug()
console.error()
console.warn()
4. document.write()
5. innerText
6. innerHTML
alert() : It pops up a message box with any specifies message and seeks
confirmation from the user. It will not allow to CANCEL (or) perform any another task
until the alert is confirmed by clicking OK.
Syntax :
alert(“Message”);
Syntax :
confirm(“Message”);
Console Functions :
A Browser debugger comprises of console were you can log the messages to
track the activities performed within the page.
The log messages can be displayed in various styles by using the methods
157
https://github.com/karrasankar158
console.info(), console.debug(), console.error(), console.warn().
Syntax :
console.log(“message/expression”);
Example :
<head>
<script>
function DeleteClick() {
console.warn("Delete Clicked");
if(status==true) {
alert("Record Deleted");
} else {
alert("Canceled");
</script>
</head>
<body>
158
https://github.com/karrasankar158
</body>
document.write() : It is an Output function that can print the output in the same
page but on a new screen. It can automatically erase when page is refresh.
Syntax :
Document.write(“message”);
Syntax :
p.innerHTML ="<b>Welcome</b>";
innerText : It is similar to innerHTML but it not allow any format for text. It is an
RC Data content.
Syntax :
p.innerText =”Welcome”;
Example :
<head>
<script>
function DeleteClick() {
159
https://github.com/karrasankar158
var msg = document.getElementById("msg");
if(status==true) {
} else {
msg.innerText="canceled";
</script>
</head>
<body>
<div class=”container”>
<div align=”center”>
</div>
</h2>
</div>
</body>
JavaScript with HTML will allow input from the user by using,
1. prompt()
160
https://github.com/karrasankar158
2. HTML form input elements
prompt() : It is an input method that popsup an input box from were user can
input value.
prompt() returns the input value when it click to OK and it returns null when it
canceled.
Syntax :
Example :
<head>
<!---link bootstrap.css-->
<script>
function CreateClick() {
var msg=document.getElementById("msg");
if(folderName==null) {
alert("You Canceled");
} else {
</script>
</head>
161
https://github.com/karrasankar158
<body>
<div class="container">
<fieldset>
<div id="msg">
</div>
</fieldset>
</div>
</body>
HTML provides several form elements that are used to input a value
dynamically. It includes textbox, checkbox, dropdown list, listbox and radio button
etc.,
You can access the element values by using the property value.
Syntax :
document.getElementById(“txtName”).value;
Example :
<!DOCTYPE html>
<html>
<head>
162
https://github.com/karrasankar158
<link rel="stylesheet"
href="../node_modules/bootstrap/dist/css/bootstrap.css">
<style>
#dialog {
width: 300px;
height: 300px;
position: fixed;
top:10px;
left:200px;
</style>
<script>
function RegisterClick(){
document.getElementById("dialog").style.display="block";
document.getElementById("fieldRegister").style.opacity="0.3";
document.getElementById("lblName").innerHTML =
document.getElementById("txtName").value;
document.getElementById("lblMfd").innerHTML =
document.getElementById("txtMfd").value;
document.getElementById("lblStock").innerHTML =
frmRegister.stock.value;
document.getElementById("lblShipped").innerHTML =
document.getElementById("lstCity").value;
163
https://github.com/karrasankar158
function OkClick() {
document.getElementById("dialog").style.display="none";
document.getElementById("fieldRegister").style.opacity="1.0";
</script>
</head>
<body>
<div class="container">
<form name="frmRegister">
<fieldset id="fieldRegister">
<legend>Register Product</legend>
<dl>
<dt>Name</dt>
<dt>Manufactured</dt>
<dt>Is In Stock</dt>
<dd>
164
https://github.com/karrasankar158
</dd>
<dt>Shipped To</dt>
<dd>
<option>Delhi</option>
<option>Hyderabad</option>
</select>
</dd>
</dl>
</fieldset>
<div class="card-header">
<h3>Product Details</h3>
</div>
<div class="card-body">
<tr>
<td>Name</td>
<td id="lblName"></td>
</tr>
<tr>
<td>Manufactured</td>
165
https://github.com/karrasankar158
<td id="lblMfd"></td>
</tr>
<tr>
<td>Is In Stock</td>
<td id="lblStock"></td>
</tr>
<tr>
<td>Shipped To</td>
<td id="lblShipped"></td>
</tr>
</table>
</div>
<div class="card-body">
</div>
</div>
</form>
</div>
</body>
</html>
Variables in JavaScript
166
https://github.com/karrasankar158
1. Variables are storage locations in memory were you store a value and use it as a
part of any expression.
A. Declaration
var x;
B. Rendering
X=10;
C. Initializing
Syntax :
<script>
function f1() {
x=10; //valid
document.write("x=" +x);
f1();
</script>
Note : If you defined “use strict”; then x=10; //invalid, it needs declaration.
Keyword Description
167
https://github.com/karrasankar158
var It defines a function scope for variable.
It supports shadowing.
Shadowing is a process of declaring same name variable within the given scope.
Syntax :
<script>
"use strict";
function f1() {
var x;
x=10;
if(x==10) {
168
https://github.com/karrasankar158
x=40;
let y;
y=20;
y=50;
const z=30;
f1();
</script>
Example :
<script>
"use strict";
function f1() {
x=10;
document.write("x=" +x);
var x; //hoisted
f1();
169
https://github.com/karrasankar158
</script>
➢ Name of variable must speak what it is i.e the purpose and reference it is used
for.
Data Types
A Data type determines the type of value that can be stored in a memory
reference.
JavaScript is implicitly typed language i.e the data type for memory is
determined according to the value assigned.
1. Primitive types
Primitive Types :
➢ Values can be directly accessed by using the name of memory allocated for
it. Hence, they are also known as “Value Types”.
170
https://github.com/karrasankar158
i. Number
ii. Boolean
iii. String
iv. Null
v. Undefined
Number Type :
JavaScript number type is used to handle numeric values, which can be any
one of the following,
Example :
<script>
"use strict"
function f1() {
f1();
171
https://github.com/karrasankar158
</script>
Boolean Type :
JavaScript boolean types can be store the boolean values true (or) false.
true = 1
false = 0
JavaScript boolean conditions can be handled directly by using zero (or) one.
Example :
<script>
"use strict"
function f1() {
var price=46555.64;
f1();
</script>
172
https://github.com/karrasankar158
String Type :
Syntax :
Syntax :
var string= `Total amount ${qty * price} you have to pay for TV`.
JavaScript string literal cannot print several special characters as they escape
printing during compilation. To print the non printable characters you have to use
the “ Escape Sequence Character “\” “.
Example :
<script>
function f1() {
173
https://github.com/karrasankar158
document.write("Path=" + path);
f1();
</script>
String Manipulation :
Function Description
Syntax :
str.charAt(0); -W
str.indexOf("e"); -1
str.lastIndexof("e"); -6
str.length -7
174
https://github.com/karrasankar158
Example :
<head>
<script>
function VerifyClick()
} else {
document.write("Email Verified");
</script>
</head>
<body>
Your Email:
<br>
<h3 id="msg"></h3>
175
https://github.com/karrasankar158
</body>
var id=
email.substring(0,email.indexOf("@"));
var domain=
email.substring(email.indexOf("@)+1);
Function Description
176
https://github.com/karrasankar158
toUpperCase() Converts to Uppercase.
Example :
<script>
function ShowTip() {
function HideTip() {
document.getElementById("msg").innerHTML="";
document.getElementById("txtName").value = uname.toUpperCase();
document.getElementById("msg").innerHTML="Hello!" +
uname.bold().italics().fontcolor('green').fontsize(5).toUpperCase();
</script>
<body>
Your Name:
<div id=”msg”></div>
</body>
177
https://github.com/karrasankar158
Example : Write logic to print any given sentence in “Sentence Case” i.e First letter of
sentence must be caps ?
<script>
function f1() {
var firstChar=msg.charAt(0);
var restChars=msg.substring(1);
document.write(newMsg);
f1();
</script>
Example : Write a program to print the given sentence in “Title Case” i.e every word
first letter must be capital ? ---------- Task
String split() : It is a string function that splits the given string at specified character
and stores in an array.
Syntax :
178
https://github.com/karrasankar158
str[0] // Welcome
str[1] // to
str[2] // javascript
Undefined Type :
➢ Undefined is a Data type specified for variables when the value is not defined.
➢ JavaScript variables are implicitly typed. Hence, if a value is not specified then
they are assigned with “undefined” key word.
Example :
<script>
function f1() {
var price;
if(price==undefined) {
document.write("Name=" + name);
}else{
f1();
</script>
Null Type :
➢ Null is assigned to reference if a value is not passed dynamically during run time.
179
https://github.com/karrasankar158
➢ The null types are verified by using the keyword “null”.
Example :
<script>
function f1() {
if(name=="") {
} else if(name==null){
document.write("You Canceled");
} else {
f1();
</script>
Note :
Undefined is a type returned when variable is defined but value not defined.
Summary
180
https://github.com/karrasankar158
String Represents sequence of characters e.g “hello”.
Non-Primitive Types
➢ They are stored in the references of main memory and accessed using the
reference memory. Hence, they are also known as reference types.
a) Array
b) Object
c) Regular Expression
Initializing Array :
➢ The meta characters can initialize memory but cannot initialize the size of
memory.
181
https://github.com/karrasankar158
➢ The Array constructor can initialize the memory and also can allocate the
memory dynamically. It can restrict the array size.
Syntax:
Values can be rendered in to an array while initializing the memory (or) after
initializing the memory.
Syntax :
(or)
values[0] = 10;
values[1] = “A”;
values[2] = true;
182
https://github.com/karrasankar158
b) Array(size); //Number
If values are not rendered in to array and memory size is defined then all values are
rendered with undefined.
Syntax :
values[1] = 10;
values[0] = 20;
prints : 20, 10
➢ You can read values from an array by using the properties of array.
➢ The index references are defined as properties and they are of Type String.
Syntax :
products[0]; //TV
products["1"] //Mobile
JavaScript provides a set of array functions that are used to read values from an
array. They are,
183
https://github.com/karrasankar158
Function Description
to String() It reads and returns the values in a string format separated with
“,”.
find() It can search for value in an array and return only the first value
that matches given condition.
filter() It is similar to “find()” but can return all values that match the
condition.
Syntax :
values.toString();
values.join("<br>");
values.slice(startIndex,endIndex);
values.find(function(){});
values.filter(function(){});
Example :
<script>
function f1(){
184
https://github.com/karrasankar158
var products = ["TV","Mobile","Shoe"];
f1();
</script>
Function Description
push() It is used to add one (or) more elements in to array towards the
end of array i.e as last item.
Syntax :
values.push("item1", "item2",....);
values.unshift("item1", "item2",...);
185
https://github.com/karrasankar158
values.splice(InsertAt, DeleteCount,"NewItems,....");
Example :
<script>
function f1(){
products.push("shoe");
products.unshift("watch");
products.splice(2,0,"Sunglasees");
document.write(products.join("<br>"));
f1();
</script>
Function Description
Example :
<script>
function f1(){
186
https://github.com/karrasankar158
var products = ["TV","Mobile","Shoe"];
document.write(products.join("<br>") + "<br>");
document.write(products.toString());
f1();
</script>
Function Description
indexOf() It can search for any value in an array and return its index
number. If the specified element not found then it returns
“-1”.
Example :
<script>
function f1(){
if(products.lastIndexOf("Mobile")==-1) {
document.write("Not Found");
} else{
187
https://github.com/karrasankar158
}
f1();
</script>
Concat Arrays :
The function “concat()” is used to combine values from multiple arrays and
store in a single array.
Example :
<script>
function f1(){
document.write(products.join("<br>") + "<br>");
f1();
</script>
Object Type
➢ The data is stored in the form of properties and logic is defined in the form of
methods.
188
https://github.com/karrasankar158
➢ Object provides re-usability for properties and methods.
Syntax :
var object = {
property : value,
method : function() {}
};
object.property;
object.method();
Example :
<script>
function f1(){
var product = {
Price : 45000.55,
Qty : 2,
IsInStock : true,
Shipped To :['Delhi','Hyd'],
Total : function(){
return product.Qty*product.Price;
},
print: function(){
189
https://github.com/karrasankar158
((Product.IsInStock==true)?"Available":"Out of Stock") + <"br>" + "Shipped To=" +
product.shippedTo.toString() + "<br>" + "Totla Amount=" + product.Total() + ",br>");
product.print();
document.write("<hr>");
product.Price : 45000.55;
product.Qty : 2;
product.IsInStock : false;
product.Shipped To :['Delhi','Hyd'];
product.Print();
f1();
</script>
➢ It is an array of objects.
<!DOCTYPE html>
<html>
190
https://github.com/karrasankar158
<!--link bootstrap.css-->
<style>
Img {
width:200px;
height:200px;
</style>
<script>
var products = [
.........
];
funcion GetDetails(index){
document.getElementById("lblName").innerHTML = products[index].Name;
document.getElementById("lblPrice").innerHTML = "&8377;" +
products[index].Price;
document.getElementById("imgProduct").src=products[index].Photo;
function bodyload(){
GetDetails(0);
var count=0;
function NextClick(){
count++;
191
https://github.com/karrasankar158
if(products.length==count){
alert("Last Product");
GetDetails(count);
function PreviousClick(){
count--;
GetDetails(count);
if(count==0){
</script>
</head>
<body onload=”bodyload()”>
<div class=”card-header”>
<h3 id=”lblName”></h3>
</div>
192
https://github.com/karrasankar158
<img id=”imgProduct” width=”200” height=”200” class=”img-thumbnail”>
</div>
<div class=”card-footer”>
<h3 id=”lblPrice”></h3>
</div>
</div>
</div>
</body>
</html>
It is a literal used to compare the format by using meta characters and quantifiers.
The values are verified with regular expression by using the function “match()”.
Syntax :
Example :
<!DOCTYPE html>
193
https://github.com/karrasankar158
<html>
<head>
<!--link bootstrap.css-->
<script>
var regExp;
var tip;
function CountryChanged(){
var flagImage;
switch(countryName)
case "India":
flagImage="../images/india.png";
regExp=/\+91[0-9]{10}/;
break;
case "US" :
flagImage="../images/us.png";
regExp=/\+001[0-9]{6}/;
break;
case "UK":
194
https://github.com/karrasankar158
flagImage=/\+4[0-9]{5}/;
break;
document.getElementById("txtMobile").placeholder=tip;
document.getElementById("flag).src=flagImage;
function VerifyMobile() {
if(mobile.match(regExp)) {
} else {
msg.style.color="red";
</script>
</head>
<body>
<div class=”container”>
<fieldset>
195
https://github.com/karrasankar158
</legend>
<dl>
<dt>Your Country</dt>
<dd>
<option value="India">India</option>
<option value="USA">USA</option>
<option value="UK">UK</option>
</select>
</dd>
<dt>Mobile Number</dt>
<dd>
</dd>
</dl>
</fieldset>
</div>
</body>
</html>
196
https://github.com/karrasankar158
Date Type :
JavaScript can handle the date values by using a “Date()” provided by date object.
Syntax :
You can read the date values and use them in date manipulations by using a set of
date functions.
Function Description
Example :
<script>
function f1() {
var product = {
197
https://github.com/karrasankar158
Price : 45000.53;
Mfd:new Date("2019/03/23")
};
vr days = ["Sunday","Monday","Tuesday","Wed","Thu","Fri","Saturday"];
document.write(`Name:${product.Name} <br>
f1();
</script>
Function Returned
Value
Math.abs(-6.5) 6.5
Math.acos(.5) 1.0
Math.asin(1) 1.5
Math.atan(5) 0.4
Math.ceil(7.6) 8
198
https://github.com/karrasankar158
Math.cos(.4) 0.9
Math.exp(8) 2980.95
Math.floor(8.9) 8
Math.log(5) 1.6
Math.max(1,700) 700
Math.min(1,700) 1
Math.pow(6,2) 36
Math.random() .7877896
Math.round(.567) 1
Math.sin(Math.PI) 0
Math.sqrt(9801) 99
Example :
<style>
dt{
font-weight:bold;
</style>
<script>
function Captcha() {
var code;
199
https://github.com/karrasankar158
var b= Math.random() * 10;
code = Math.round(a) + " " + Math.round(b) + " " + Math.round(c) + " " +
Math.round(d) + " " + Math.round(e) + " " + Math.round(f);
return code;
function bodyload() {
document.getElementById("lblCode").innerHTML = Captcha();
</script>
<body onload="bodyload()">
<fieldset>
<legend>User Login</legend>
<dl>
<dt>User Name</dt>
<dd><input type="text"></dd>
<dt>Password</dt>
<dd><input type="password"></dd>
<dt>Verify Code</dt>
<dd id="lblCode"></dd>
200
https://github.com/karrasankar158
</dl>
</fieldset>
</body>
Operators in JavaScript
➢ The operators are categorized in to 3 groups based on no.of operands they can
handle.
a) Unary Operator
- one operand
Ex: x++
b) Binary Operator
- two operands
Ex: x + y
c) Ternary operator
-three operands
Ex : (condition)?true:false
The operators are classified in to several types based on the type of value they
return,
1. Arithmetic Operators
201
https://github.com/karrasankar158
3. Bitwise Operators
4. Logical Operators
5. Assignment Operators
6. Special Operators
+ Addition 10+20=30
- Subtraction 20-10=10
* Multiplication 10*20=200
/ Division 20/10=2
% Modulus 20%10=0
(Remainder)
Now a =11
Now a=9
** Exponent 2**3=8
Var y=-x,
X=10, Y=-10
Addition :
202
https://github.com/karrasankar158
Number + String = String
Substraction :
203
https://github.com/karrasankar158
Increment and Decrement :
➢ Increment adds the current value with one and assigns to the current value.
Syntax :
var x=10
x++;
x=x+1 = 11
Post Increment :
Syntax :
var x = 10;
var y = x++;
O/P :
x=11;
y=10;
Pre Increment :
Syntax :
var x=10;
var y=++x;
O/P:
204
https://github.com/karrasankar158
x=11
y=11
Decrement :
It decrements the current value by one and assigns to the current reference. It
can also be defined as,
1. Post decrement :
var x=10;
var y=x--;
O/P:
x=10
y=9
2. Pre decrement :
var x=10;
var y=--x;
O/P:
x=9
y=9
Exponent Operator :
It is represented with “ * * “.
“Math.pow()”
205
https://github.com/karrasankar158
Example :
var x=2;
var y=3;
x**y; //8
Math.pow(x,y); //8
Comparison Operators :
== Is equal to 10==20=false
Note : Identical equal can compare only the values if they are of same type.
Syntax :
var x=10;
var y="10";
206
https://github.com/karrasankar158
x==y; //true
x===y; //false
Bitwise operators :
Logical Operators :
|| Logical OR ( 10==20=&&20==33)=false
Assignment Operators :
207
https://github.com/karrasankar158
Operator Description Example
= Assign 10+10=20
Now a=30
Now a=10
Now a=200
Now a=5
Now a=0
Special Operators :
1. Ternary Operator :
It is a special operator that handles the three operands, which includes a condition,
statement if true and statement if false.
Syntax :
(condition)?statement_true: statement_false
2. delete :
It is a special operator used to delete any property from an object you cannot
delete the properties of built in objects like,
208
https://github.com/karrasankar158
Example :
<script>
function f1() {
var product = {
Name: "Tv",
Price: 45000.64
};
delete product.Price;
f1();
</script>
3. typeof :
It is a special operator that can verify and return the type of value stored in any
reference.
Syntax :
var x=10;
typeof x; //number
Example :
<script>
209
https://github.com/karrasankar158
function f1() {
var product = {
Name: "Tv",
Price: 45000.64,
Stock: true
};
f1();
</script>
4. instanceof :
It is a boolean operator that verifies the given object with specified class and
return a boolean true (or) false.
Example :
<script>
class Product {
function f1() {
210
https://github.com/karrasankar158
document.write(product instanceof Product);
f1();
</script>
in Operator :
It verifies whether the given property is available in specified object and returns
boolean true (or) false.
Syntax :
“Property” in object
Example :
<script>
function f1() {
var product = {
Name: "TV",
Price:56000.66
};
f1();
</script>
of Operator :
It is used to verify and read all values in a collection. It is used over iterations.
211
https://github.com/karrasankar158
Example :
<script>
function f1() {
document.write(value + "<br>");
f1();
</script>
void Operator :
It is a special character used to define that the given function (or) object doesn’t
return any value i.e without any return type.
Example :
<body>
<a href="javascript:void()">Home</a>
</body>
new Operator :
Example :
<script>
212
https://github.com/karrasankar158
function bodyload() {
pic.width="100";
pic.height="100";
pic.src="../images/tv.jpg";
doucment.getElementById("conatiner").appendChild(pic);
</script>
<body onload="bodyload()">
<h3>Image Below</h3>
<div id="container"></div>
</body>
Statements in JavaScript
➢ The statements are program instructions used to control the execution flow.
➢ Statements are categorized in to following types based on how they control the
flow.
a) Selection Statements
b) Iteration Statements
c) Jump Statements
213
https://github.com/karrasankar158
Selection Statements
➢ A program executes in sequential order you can change the execution order by
using the selection statement.
1. forward Jump
2. simple Decisions
3. multiple Decisions
4. multi Level
forward jump :
In this technique the statement execution will continue only when the given
condition is satisfied. There will be no alternative process.
///////////////////////fig///////////////////////////////////////
if(condition/booleanExpression)
statement if true;
214
https://github.com/karrasankar158
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet"
href="../node_modules/bootstrap/dist/css/bootstrap.css">
<script>
var userDetails = {
CardNo: "5555666688887777",
Year:"2019",
Cvv:"3344"
};
function VerifyCard() {
if(userDetails.CardNo==cardnumber) {
document.getElementById("lstYear").disabled=false;
function VerifyYear(){
if(userDetails.Year==year) {
document.getElementById("txtCvv").disabled=false;
function VerifyCvv(){
215
https://github.com/karrasankar158
var cvv = document.getElementById("txtCvv").value;
if(userDetails.Cvv==cvv) {
document.getElementById("btnPay").disabled=false;
</script>
</head>
<body>
<div class="container">
<fieldset>
<dl>
<dt>Card Number</dt>
<dt>Expiry Year</dt>
<dd>
<option>2019</option>
<option>2020</option>
<option>2021</option>
</select>
</dd>
216
https://github.com/karrasankar158
<dt>CVV</dt>
<dd>
</dd>
</dl>
</fieldset>
</div>
</body>
</html>
Exercise :
217
https://github.com/karrasankar158
218
https://github.com/karrasankar158
219
https://github.com/karrasankar158
Example : KFC
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet"
href="../node_modules/bootstrap/dist/css/bootstrap.css">
<style>
.setMargin {
margin-top: 20px;
background-color: maroon;
color:white;
width:900px;
font-size: 2em;
text-align: center;
</style>
<script>
function OrderClick() {
document.getElementById("frmRegister").style.display="none";
document.getElementById("frmDetails").style.display="block";
220
https://github.com/karrasankar158
var customerName = document.getElementById("txtName").value;
var mealName;
var mealCost;
var adonName="";
var adonCost;
if(optBurger.checked) {
mealName=optBurger.value;
mealCost=130;
if(optRoller.checked) {
mealName=optRoller.value;
mealCost=100;
if(optWings.checked) {
adonName+=optWings.value + "<br>";
adonCost=80;
221
https://github.com/karrasankar158
mealCost=mealCost + adonCost;
if(optKrusher.checked) {
adonName+=optKrusher.value + "<br>";
adonCost=40;
mealCost=mealCost + adonCost;
document.getElementById("lblName").innerHTML=customerName;
document.getElementById("lblMeal").innerHTML=mealName;
document.getElementById("lblAdon").innerHTML = adonName;
document.getElementById("lblAmount").innerHTML = "₹" +
mealCost;
function CloseClick() {
document.getElementById("frmRegister").style.display="block";
document.getElementById("frmDetails").style.display="none";
</script>
</head>
<body>
<div class="container">
<div id="frmRegister">
<div class="setMargin">
222
https://github.com/karrasankar158
</div>
<div class="setMargin">
Customer Details
</div>
<label>Customer Name</label>
</div>
<div class="setMargin">
Select a Meal
<div class="card-deck">
<div class="card">
<div class="card-body">
<img src="../Images/omg1.PNG"
class="img-thumbnail">
</div>
₹ 130/-
</div>
</div>
<div class="card">
223
https://github.com/karrasankar158
<div class="card-body">
<img src="../Images/omg2.PNG"
class="img-thumbnail">
</div>
₹ 100/-
</div>
</div>
</div>
</div>
<div class="setMargin">
Select AD-ON
<div class="card-deck">
<div class="card">
<div class="card-body">
<img src="../Images/wings.PNG"
class="img-thumbnail">
</div>
224
https://github.com/karrasankar158
₹ 80/-
</div>
</div>
<div class="card">
<div class="card-body">
<img src="../Images/krusher1.PNG"
class="img-thumbnail">
</div>
₹ 40/-
</div>
</div>
</div>
</div>
</div>
</div>
<h2>Order Details</h2>
225
https://github.com/karrasankar158
<table class="table table-hover table-danger" style="font-size:
2em;">
<tr>
<td>Customer Name</td>
<td id="lblName"></td>
</tr>
<tr>
<td>Selected Meal</td>
<td id="lblMeal"></td>
</tr>
<tr>
<td>Selected Ad-On's</td>
<td id="lblAdon"></td>
</tr>
<tr>
<td>Total Amount</td>
<td id="lblAmount"></td>
</tr>
<tr>
</td>
</tr>
226
https://github.com/karrasankar158
</table>
</div>
</div>
</body>
</html>
Simple Decision :
In this approach the conditions are defined with an else clause, so that the
statements are defined for both condition true (or) false.
Syntax :
if (booleanExpression)
statements if true;
else
statements if false;
Multiple Decisions :
227
https://github.com/karrasankar158
It is a technique where multiple alternatives are provided to handle any
specified task.
Syntax :
if (condition1)
else if (condition2)
else
It allows to check the next conditions only when the given first condition is
satisfied.
Syntax :
228
https://github.com/karrasankar158
if(condition-1) {
if(condition-2) {
if(contion-3){
} else {
} else {
else {
Switch Statement :
A selector switch will execute only the specified without verifying the other
statements defined in the context.
229
https://github.com/karrasankar158
Syntax :
switch (expression)
case constant-expression:
statement
jump-statement
[default:
statement
jump-statement]
Example :
230
https://github.com/karrasankar158
<script>
function GetClick() {
var n = document.getElementById("txtNo").value;
switch(n)
case "1":
msg.innerHTML = "ONE";
break;
case "2":
msg.innerHTML="TWO";
break;
case "3":
msg.innerHTML="THREE";
break;
default:
break;
</script>
<body>
Number:
231
https://github.com/karrasankar158
<input type="text" id="txtNo">
<button onclick="GetClick()">Get</button>
<br>
<div id="msg"></div>
</body>
FAQ’s :
A. Yes
A. Yes
Example :
<script>
function f1() {
var x = "N";
switch(x){
case "y":
case "Y":
document.write("Selected Yes");
232
https://github.com/karrasankar158
break;
case "n":
case "N":
document.write("Selcted No");
break;
default:
document.write("Choose y or n");
f1();
</script>
A. Convert the input string in to any one specified CASE i.e upper or lower.
Example :
var x = "YES";
switch(x.toLowerCase()) {
case "yes":
.....
break;
233
https://github.com/karrasankar158
A. Yes.
A. Yes.
A . By passing a boolean value in to switch and defining case with boolean condition.
Example :
<script>
function f1() {
var x = 7;
switch(true){
break;
break;
default:
break;
234
https://github.com/karrasankar158
}
f1();
</script>
Task :
/////////////////fig////////////////////////////
Syntax :
235
https://github.com/karrasankar158
{
statement;
Example :
document.wrtie(i + "<br>");
Example :
document.write(i + "<br>");
Example :
document.write(i + "<br>");
236
https://github.com/karrasankar158
Skip Counter in loop :
Terminate Loop :
The looping control statements can be terminated by using any condition and
jump statement i.e break (or) return.
Example :
<head>
<script>
var users =[
{UserName:"john123"},
{UserName:"john"},
{UserName:"john_ui"},
{UserName:"david"}
];
function VerifyUser(){
237
https://github.com/karrasankar158
var msg = document.getElementById("msg");
if(username==users[i].UserName){
msg.style.color="red";
break;
} else {
msg.style.color="green";
</script>
</head>
<body>
<fieldset>
<div id="msg"></div>
</body>
238
https://github.com/karrasankar158
Example :
<script>
var products = [
];
function bodyload() {
var li = documetn.createElement("li");
li.innerHTML=products[i].Category;
list.appendChild(li);
nestedLi.innerHTML=products[i].Items[j];
ul=document.createElement("ul");
ul.appendChild(nestedLi);
li.appendChild(ul);
</script>
<body onload="bodyload()">
239
https://github.com/karrasankar158
<ol id="list">
</body>
Class Example :
Source Code -
<head>
<style>
#imgProduct {
Width:200px;
height: 200px;
#status {
width: 50;
height: 60;
position: fixed;
right: 10;
top: 10;
text-align: center;
cursor:grab;
240
https://github.com/karrasankar158
#count{
font-weight: bold;
color: red;
font-size: 1em;
text-align: center;
</style>
<script>
var categories = [
"Select a Category",
"Electronics",
"shoes"
];
function bodyload(){
option.text = categories[i];
option.value=categories[i];
lstCategories.appendChild(option);
var electronics = [
241
https://github.com/karrasankar158
"Select Electronic Product",
"Samsung Tv",
"MI Mobile"
];
var shoes = [
"Nike Casuals",
];
function AddProducts(collection){
var lstProducts=document.getElementById("lstProducts");
lstProducts.innerHTML="";
option.text=collection[i];
option.value=collection[i];
lstProducts.appenChild(option);
function CategoryChanged(){
switch(category){
case "Electornics":
242
https://github.com/karrasankar158
AddProducts(electronics);
break;
case "Shoes" :
AddProducts(shoes);
break;
default:
document.getElementById("lstProducts").innerHTML="";
var productsData = [
function ProductChange(){
window.product=productsData.filter(x=>.Name==prodyctName);
document.getElementById("lblName").innerHTML=product[0].Name;
document.getElementById("lblPrice").innerHTML="&8377;" + product[0].Price;
document.getElementById("imgProduct").src=product[0].Photo;
var cartItems=[];
243
https://github.com/karrasankar158
function AddToCartClick(){
cartItems.push(product[0]);
var totalAmount=0;
var tbody=document.getElementById("tbody");
var tr=document.crateElement("tr");
var td1=document.createElement("td");
var td2=document.createElement("td");
var td3=document.createElement("td");
td1.innerHTML=cartItems[i].Name;
td2.innerHTML=cartItems[i].Price;
img.src=cartItems[i].Photo;
img.height=50;
img.width=50;
td3.appendChild(img);
tr.appendChild(td1);
tr.appendChild(td2);
tr.appendChild(td3);
tbody.appendChild(tr);
244
https://github.com/karrasankar158
document.getElementById("count").innerHTML=cartItems.length;
document.getElementById("lblAmount").innerHTML=totalAmount;
function ShowCart(){
document.getElementById("cart").style.display="block";
</script>
</head>
while :
The while loop is used when the exact number of iterations are not known and
when iteration counter may change dynamically. It will start the loop only when the
condition evaluates to true.
//////////////////////fig////////////////////
Syntax :
while (booleanExpression)
counter;
245
https://github.com/karrasankar158
statements;
Example :
var i=0;
while(i<10) {
i++;
document.write(i+ "<br>");
do while :
It is similar to while loop but gurantee that the statements will execute atleast
once even when the condition is false.
///////////////////////////fig////////////////////
Syntax :
do
counter;
statements;
} while(booleanExpression);
246
https://github.com/karrasankar158
Example :
<script>.
function f1() {
var i=11;
do{
if(i>10) {
document.write("Can't Loop");
} else {
i++;
document.write(i + "<br>");
while(i<10);
f1();
</script>
Note : Task
247
https://github.com/karrasankar158
Functions in JavaScript
248
https://github.com/karrasankar158
Anonymous Function :
➢ The functions that are defined without name are known as Anonymous
Functions.
➢ They are mostly used in call back mechanism where functions execute
automatically according to specified condition.
Example :
<script>
(function(){
document.write("Hello ! <br>");
document.write("Welcome");
})()
</script>
249
https://github.com/karrasankar158
Named Functions :
A function defined with specified name so that it can be accessed from any
location by using the name.
Example :
<script>
function Hello(){
document.write("Hello ! <br>");
document.write("Welcome");
Hello();
</script>
Referred Functions :
These are the functions not defined with any name and loaded in to memory.
You can assign a memory reference for function and access it by using the
reference name [ not function name].
Example :
<script>
var hello=function() {
document.write("Hello ! <br>");
250
https://github.com/karrasankar158
hello();
</script>
➢ You can configure a single reference in memory that can access multiple
functions.
Example :
<script>
var math = {
Add: function(){
document.write("Addition=" + (10+20));
},
Multiply: function(){
document.write("Multiply=" + (5*6));
math.Multiply();
math.Add();
</script>
251
https://github.com/karrasankar158
Function Parameters :
➢ A parameter less function is used to perform the same functionality for every
situation.
➢ The parameters passed while calling the function are known as “Actual
Parameters”.
Example :
<script>
function PrintNumbers(howMany){
document.write(i + "<br>" );
function PrintMessage(userName) {
PrintNumbers(5);
PrintMessage("John");
</script>
Multiple Parameters :
252
https://github.com/karrasankar158
➢ Every parameter is responsible for modifying specific value in a function.
Example :
<style>
div {
margin-top: 10px;
</style>
<script>
</script>
Optional Parameters :
Example :
253
https://github.com/karrasankar158
<script>
if(price==undefined) {
} else {
PrintProduct("Samsung TV");
</script>
Array Parameters :
An array parameter is reference type parameter which can handle a list of values in
any function.
The actual values in to parameter can be passed by using array type meta character
“[]” (or) “Array()”.
Example :
<script>
function PrintList(yourList){
document.write(item + "<br>");
254
https://github.com/karrasankar158
}
var electronics=["TV","Mobile"];
PrintList(electronics);
PrintList(["Watc", "Sunglasses"]);
</script>
Rest Parameters :
➢ A rest Parameter allows a function to define one formal parameter which can
access multiple values.
Example :
<script>
function PrintList(...yourList){
document.write(item + "<br>");
</script>
Note :
255
https://github.com/karrasankar158
1. Every function can be defined with only one rest parameter.
The JavaScript functions can be defined with a return value so that they can execute
the given statements, evaluate a value and store the return value.
Syntax :
function Name(params) {
return value;
FAQ :
A. Yes.
Ex :
<script>
function Login(pwd) {
if(pwd=="admin") {
return "success..";
} else {
return "invalid";
256
https://github.com/karrasankar158
}
document.write(Login("admin"));
</script>
Function Recursion :
Recursion is a technique were a function is defined with relative access within the
scope i.e a function called within the same function.
Example :
<script>
function fact(n) {
if(n<=0) {
return 1;
} else {
return n * fact(n-1);
document.write(fact(6));
</script>
OOP in JavaScript
257
https://github.com/karrasankar158
➢ The re-usability of objects was designed in early 1960’s by Johan Olay and
Kristien Nyaggard with a language called SIMULA.
➢ The code separation with re-usability was designed in early 1970’s by Trygve. He
introduced a framework called MVC [ Model View Controller ].
Features of OOP :
◆ Code Re-usability
◆ Code Security
◆ Code Separation
◆ Code Extensibility
◆ Code Testability
Drawbacks of OOP :
✓ Slow in responding
✓ Heavy applications
Characteristics of OOP :
⚫ Inheritence
⚫ Polymorphism
⚫ Encapsulation
258
https://github.com/karrasankar158
⚫ Abstraction
Class in JavaScript :
➢ It is an logical entity that provides a set of members that are used to store data
and handle the logic.
A. Constructor
B. Properties
C. Methods
➢ The members in a class are accessible within the class by using the keyword “this”
and outside the class they are accessible by using an object.
Syntax :
class className {
constructor() {}
property;
method() {};
259
https://github.com/karrasankar158
Example :
<style>
dl {
width:200px;
border-radius:10px;
margin:10px;
floar:left;
dt{
font-weight:bold;
background-color:light cyan;
</style>
<script>
class Product {
Name="";
Price=0.0;
Qty=0;
Total(){
};
260
https://github.com/karrasankar158
Print(){
document.write(`
<dl>
<dt>Name</dt>
<dd>${this.Name}</dd>
<dt>Price</dt>
<dd>${this.Price}</dd>
<dt>Quantity</dt>
<dd>${this.Qty}</dd>
<dt>Total</dt>
<dd>${this.Total()}</dd>
</dl>
`);
tv.Name="Samsung TV";
tv.Price=35400.55;
tv.Qty=2;
tv.Print();
shoe.Name="Nike Casuals";
shoe.Price=4200.44;
261
https://github.com/karrasankar158
shoe.Qty=3;
shoe.Print();
</script>
Constructor :
✓ The constructor methods are anonymous i.e they cannot contain a name the
class name is given to constructor.
Example :
<script>
class Database{
constructor(){
doxument.write("Connected to Database....<br>");
Insert(){
document.write("Record Inserted<br>");
Delete(){
262
https://github.com/karrasankar158
document.write("Record Deleted<br>");
function InsertClick(){
obj.Insert();
function DeleteClick(){
obj.Delete();
</script>
<body>
<button onclick="InsertClick()">Insert</button>
<button onclick="DeleteClick()">Delete</button>
</body>
Parameterized Constructor :
The parameters in to constructor are passed while allocating memory for class.
Example :
263
https://github.com/karrasankar158
<script>
class Database {
constructor(dbName){
Insert(){
document.write("Record Inserted<br>");
Delete(){
document.wrtie("Record Deleted<br>");
function InsertClick(){
var db=document.getElementById("lstDb").value;
obj.Insert();
function DeleteClick(){
var db=document.getElementById("lstDb").value;
obj.Delete();
</script>
264
https://github.com/karrasankar158
<body>
<div>
<fieldset>
<legend>Select Database</legend>
<select id="lstDb">
<option>Oracle</option>
<option>Mysql</option>
<option>MongoDB</option>
</select>
<button onclick="InsertClick()>Insert</button>
<button onclick="DeleteClick()>Delete</button>
</fieldset>
</div>
</body>
265
https://github.com/karrasankar158
Code Re Usability :
➢ It is a technique that allows to re-use the code without re-writing the code.
1. Aggregation
2. Inheritance
Aggregation :
It is a technique that allows to access the members of one class in another class
without creating any relationship between classes. It uses “Object-to-Object”
communication and is known as “Has-A-Relation”.
Example :
<script>
class Camera {
Pixels;
Print(){
document.write(`Camera - ${this.Pixels}<br>`);
class Memory {
RAM;
Print(){
document.write(`Memory - ${this.RAM}<br>`);
266
https://github.com/karrasankar158
}
class Mobile {
Print(){
camera.Pixels="20px";
memory.RAM="4GB";
camera.Print();
memory.Print();
mobile.Print();
</script>
Inheritance :
It is a technique that allows to re-use the code without re-writing the code by
configuring relationship between classes, which is known as “Is-A-Relation”.
The newly extended class is known as “Derived Class” and existing class is known as
“Super Class”.
267
https://github.com/karrasankar158
The members of super class are accessible in derived class by using the keyword
“super”.
Every class can extended only one super class, it will support multilevel inheritance
but not multiple inheritance.
Syntax :
class Base {
Note :
Example :
<script>
class Camera {
268
https://github.com/karrasankar158
Pixels = "20px";
Print(){
document.write(`Camera - ${this.Pixels}<br>`);
RAM = "4GB";
Print(){
super.Print();
document.write(`Memory - ${this.RAM}<br>`);
Print(){
super.Print();
mobile.Print();
</script>
Note : A super class constructor is shared to derived class hence avoid using a
constructor in derived class.
269
https://github.com/karrasankar158
Polymorphism
Poly = Many
Morphos = forms
Example :
<script>
class Employee {
firstName="";
lastName="";
Print(){
firstName="Raj";
lastName="Kumar";
Print(){
270
https://github.com/karrasankar158
}
firstName="Tom";
lastName="Hanks";
Print(){
firstName="Rakesh";
lastName="Kumar";
Print(){
employees[i].Print();
271
https://github.com/karrasankar158
}
</script>
a. Properties
b. Methods
c. Events
Event is a message sent by sender to its subscriber in order to notify the change. It
follows a software design pattern called “Observer”.
Syntax :
function InsertClick()
272
https://github.com/karrasankar158
<button onclick="InsertClick">
Event handler is function pointer that uses Delegate mechanism i.e pointing towards
the same signature function.
a. this
b. event
The parameter “this” can give access to all properties and methods of current object.
The “event” parameter can give access to all event related properties and methods.
Syntax: :
The object Properties are name, value, id, className, style etc.,
273
https://github.com/karrasankar158
Example :
<script>
function btnClick(obj){
qwitch(obj.value) {
case "Insert" :
document.write("Record Inserted");
bresk;
case "Delete":
document.write("Record Deleted");
</script>
<body>
</body>
274
https://github.com/karrasankar158
/////////////////////////INCOMPLETE/////////////////////////////////////
275
https://github.com/karrasankar158
oncut
oncopy
Example :
<head>
<script>
function Copy() {
document.getElementById("status").innerHTML="Mobile No Copied";
function Cut() {
document.getElementByID("status").innerHTML="Mobile No is in Memory";
function Paste() {
document.getElementById("status").innerHTML="Mobile No Inserted";
</script>
</head>
<body>
<div>
Mobile:
276
https://github.com/karrasankar158
<span id=”status”></span>
</div>
</body>
FAQ :
Example :
<head>
<script>
document.oncontextmenu = function(){
return false;
</script>
</head>
277
https://github.com/karrasankar158
<body oncontextmenu="return false" onselectstart="return flase" onselect="return
false" oncopy="return false">
</body>
onsubmit
onreset these are the events associated with form element, which are
used to specify actions to perform when user clicks submit (or) reset buttons.
Example :
<head>
<script>
function SubmitClick(){
function ResetClcik(){
</script>
</head>
278
https://github.com/karrasankar158
<body>
Name :
</form>
</body>
Timer Events :
1. setTimeout() :
It is used to load any task in to memory and lock the task for a specific duration.
It will release the task in to process after the specified time interval.
Syntax :
setTimeout(function(){}, timeInterval);
2. clearTimeout() :
It is a timer event used to kill the task in memory. It can remove the specified
task from memory before execution.
Syntax :
clearTimeout(funtionreference);
279
https://github.com/karrasankar158
Example :
<head>
<script>
function msg1() {
document.getElementById("msg").innerHTML="Hello !";
function msg2() {
functio msg3() {
document.getelementById("msg").innerHTML="Welcome to JavaScript";
function bodyload(){
window.m1=setTimeout(msg1,2000);
window.m2=setTimeout(msg2,4000);
window.m3=setTimeout(msg3.6000);
function CancelClick() {
clearTimeout(m2);
</script>
</head>
<body onload="bodyload()">
280
https://github.com/karrasankar158
<h2 align="center" id="msg"></h2>
</body>
setInterval :
It is a timer function which loads the given task in to memory and executes at
regular time intervals until the task is erased from memory.
You can erase the task from memory by using clear interval.
Syntax :
setInterval(function(){}, timeInterval);
clearInterval(functionReference);
Example :
<head>
<script>
function Clock(){
document.getElementById("msg").innerHTML=now.toLocateTimeString();
function bodyload(){
window.time=setInterval(Clock,1000);
function StopClick(){
281
https://github.com/karrasankar158
clearInterval(time);
function StartClick(){
window.time=setInterval(Clock,1000);
</scipt>
</head>
<body onload="bodyload()">
<button onclick="StopClick()">Stop</button>
<button onclick="StartClick()">Start</button>
</body>
Example :
<head>
<script>
var products = [
......
282
https://github.com/karrasankar158
];
function ShowImage(index){
document.getElementById("lblName").innerHTML=products[index].Name;
document.getElementById("lblPrice").innerHTML=products[index].Price;
document.getElementById("imgProduct").innerHTML=products[index].Photo;
var i=0;
function SlideShow(){
i++;
ShowImage(i);
if(i==products.length) {
clearInterval(show);
fucntion PlayClick(){
window.show=setInterval(SlideShow,5000);
function PauseClick()[
clearInterval(show);
283
https://github.com/karrasankar158
</script>
</head>
<body onload="ShowImage(0)">
<div class="container">
Amazon Products
<br>
(<span id="status">Manual</span>)
</h2>
<div class="card-header">
<h2 id="lblName"></h2>
</div>
<div class="card-body">
</div>
<div class="card-footer">
<h3 id="lblPrice"></h3>
</div>
</div>
284
https://github.com/karrasankar158
</div>
</body>
Example :
<head>
<style>
progress {
width:400px;
</style>
<script>
var i=0;
function Download(){
i = i+2;
function StartDownload() {
window.x=setInterval(Download,1000);
function PauseDonwload() {
clearInterval(x);
285
https://github.com/karrasankar158
}
</script>
</head>
<body>
<fieldset>
<legend>
Download Software
<br>
<div id="lblStatus"></div>
</legend>
<br><br>
</fieldset>
</body>
1. window :
It provides a set of properties and methods that are used to control the
browser window. The methods are,
Method Description
286
https://github.com/karrasankar158
open() It opens the specified document (or) URL in a new
window.
Syntax :
window.close();
window.print();
Example :
<head>
<script>
function OpenPic() {
</script>
</head>
<body>
<br>
287
https://github.com/karrasankar158
<button onclick="window.print()">Print Page</button>
</body>
2. Location Object :
The javascript location object provides a set of properties and methods that are
used to access the client location details which includes the following,
Member Description
protocol It returns the current protocol i.e file, http, https etc.,
Syntax :
location.host;
location.href;
Example :
<head>
<style>
288
https://github.com/karrasankar158
dt{
font-weight: bold;
background-color: lightyellow;
</style>
<script>
function GetDetails(){
document.getElementById("server").innerHTML=location.host;
document.getElementById("url").innerHTML=location.href;
document.getElementById("path").innerHTML=location.pathname;
</script>
</head>
<body>
<button onclick="location.reload()">Reload</button>
<dl>
<dt>Server/IP Address</dt>
<dd id="server"></dd>
<dt>Protocol</dt>
289
https://github.com/karrasankar158
<dd id="protocol"></dd>
<dt>URL</dt>
<dd id="url"></dd>
<dt>Page Path</dt>
<dd id="path"></dd>
</dl>
</body>
<head>
<style>
div {
margin-top: 20px;
</style>
<script>
var tutorial = [
Topic : "JavaScript",
},
Description : "it comprised of various tools and languages to build progressive web
applications"
290
https://github.com/karrasankar158
}
];
function GetQueryString(){
var querystring=location.search;
results = tutorial.filter(x=>x.Topic==word);
</script>
</head>
<body>
<div align="center">
<form>
<div>
</div>
<div>
</div>
<div>
291
https://github.com/karrasankar158
</div>
<div id="result">
</div>
</form>
</div>
</body>
Location Hash :
It is a location property is used to access current hash location, which refers to any
named location in page.
Example :
<script>
function GetLocation() {
var loc=location.hash;
switch(loc) {
case "#html":
break;
292
https://github.com/karrasankar158
case "#css":
break;
cae "#js":
break;
</script>
Navigator Object
The JavaScript navigator object provides a set of properties and methods that are
used to access the client browser details. It includes the following,
Member Description
293
https://github.com/karrasankar158
cookieEnabled Cookie status, blocked (or) Enabled.
Syntax :
navigator.cookieEnabled;
navigator.language;
Example :
<head>
<script>
function bodyload(){
document.getElementById("msg").innerHTML=`Cookies Status :
${(navigator.cookieEnabled)?"Cookie Enabled":"Blocked - Please Enable
Cookies"}<br>
</script>
</head>
<body onload="bodyload()">
<div id="msg">
</div>
</body>
294
https://github.com/karrasankar158
function bodyload() {
alert(item.name);
<body onload="bodyload()"></body>
<script>
function bodyload(){
location.href="http://www.adobe.co/download";
} else {
</script>
<body onload="bodyload()">
<a href="../Docs/cssdemo.pdf">Tutorial</a>
</body>
295
https://github.com/karrasankar158
navigator.mimeTypes[0].type
History Object
It is a browser object used to access the client browsing history details. It includes
the following members,
Member Description
goto(2) - forward 2
goto(-2) - back 2
goto(‘home.html’)
Syntax :
296
https://github.com/karrasankar158
JOuery
➢ JQuery provides functions to manipulate CSS and HTML. It’s intention is write
less and do more.
➢ JQuery provides cross browser functionality so that its functions are executable
from any location [ Browser ] .
Installing JQuery :
2. C:\Amazon>
Node_modules
Jquery
Dist
Jquery.js
297
https://github.com/karrasankar158
<script>
<script>
Example :
<head>
<script src="../node_modules/jquery/dist/jquery.js"></script>
<script>
$(document).ready(function() {
document.write("Welcome to JQuery");
})
</script>
</head>
<body>
</body>
JQuery Selectors :
A selector is used to refer HTML elements dynamically. The commonly used selectors
are,
b) Id selector $(“#id”)
298
https://github.com/karrasankar158
c) Class selector $(“.class”)
Example :
<head>
<script src=".....jquery.js"></script>
<script>
$(document).ready(function(){
})
</script>
</head>
<body>
<h2></h2>
<p id="para"></p>
<div class="divClass"></div>
</body>
Note :
JQuery cannot access attribute of HTML element directly. It requires the function
“attr()”.
Syntax :
$(“img”).attr(“src”, “../images/tv.jpg”);
$(“td”).attr(“colspan”,2);
299
https://github.com/karrasankar158
<head>
<link bootstrap.css>
<script scr="..jquery.js"></script.
<script>
var product = {
Price : 45000,
Photo : "../images/tv.jpg"
};
$(document).ready(function(){
$("#prodName").text(product.Name);
$("#prodPrice").text(product.Price);
$("#prodImg").attr("src",product.Photo);
})
</script>
</head>
<body>
<div class="container">
<div class="card">
<div class="card-header">
<h2 id="prodName"></h2>
300
https://github.com/karrasankar158
</div>
<div class="card-body">
</div>
<div class="card-footer">
<h2 id="prodPrice"></h2>
</div>
</div>
</div>
</body>
1. html() :
It is a jquery function used to append text in to any html container with formats
[ innerHTML ].
Syntax :
2. text() :
It is similar to html function but will not support format for texts. It is used for
presenting RC Data elements.
Syntax :
301
https://github.com/karrasankar158
3. css() :
Syntax :
$("p").css("Property", “value”);
$("p").css({property:value, …});
Example :
<head>
<script src="...jquery.js"></script>
<script>
$(document).ready(function(){
})
</script>
</head>
<body>
<p id=p1"></p>
<p id="p2"></p>
<p id="p3"></p>
<p id="p4"></p>
302
https://github.com/karrasankar158
</body>
4. val() :
It is a jquery property used to access the value of any html input element. It can
also set a value in to the element.
Syntax :
$("#txtName").val("john");
var name=$("#txtName").val();
5. attr() :
Syntax :
$("img").attr("src")="images/pic.jpg";
Example :
<head>
<script src=...jquery.js"></script>
<script>
$(document).ready(function(){
$("#btnSubmit").click(function(){
var name=$("#txtName").val();
var city=$("#lstCity").val();
303
https://github.com/karrasankar158
$("#details").html(`<dl><dt>Name</dt><dd>${name}</dd><dt>Stock
Status</dt><dd>${stock}</dd><dt>Shipped To</dt><dd>${city}</dd></dl>`)
})
})
</script>
</head>
<body>
<h2>Register</h2>
<dl>
<dt>Name</dt>
<dt>Shipped To</dt>
<dd>
<select id="lstCity">
<option>Delhi</option>
<option>HYD</option>
</select>
</dd>
<button id="btnSubmit">Submit</button>
</dl>
<div>
<h2>Details</h2>
<p id="details"></p>
</div>
304
https://github.com/karrasankar158
</body>
Iterations in JQuery :
JQuery can use all JavaScript iterators but it is in-built provided with the function
Syntax :
append() :
Syntax :
$("p").append("some text/element")
Example :
<head>
<script src="...jquery.js"></script>
<script>
$(document).ready(function(){
var products=["TV","Mobile","Shoe"];
$("#list").append(`[${key}] ${value}<br>`);
})
305
https://github.com/karrasankar158
})
</script>
</head>
<body>
<div id="list">
</div>
</body>
prepend() :
It is a jquery function used to add any new content in to existing content as prefix.
remove() :
appendTo() :
It adds a new element in to existing element by using parent and child hierarchy.
Example :
<head>
<script src=..jquery.js></script>
<script>
$(document).ready(function(){
$("#btnAdd").click(fucntion(){
306
https://github.com/karrasankar158
$("<h2>Details Added to Page</h2>").appendTo("#details");
})
$("#btnRemove").click(function(){
$("h2").remove();
})
})
</script>
</head>
<body>
<div>
<button id="btnRemove">Remove</button>
<button id="btnAdd">Add</button>
</div>
<div id="details">
</div>
</body>
Example :
307
https://github.com/karrasankar158
<ol id=”list”> </ol>
$(document)ready.(function()
})
Answer :
<script>
$(document).ready(function(){
$(`<li>${value}</li>`).appendTo("#list");
})
})
</script>
<body>
<ol id="list"></ol>
</body>
Example :
var products = [
];
<ol id="list"></ol>
308
https://github.com/karrasankar158
Answer :
<script>
var products = [
];
$(document).ready(function(){
$.each(products)function(key,value);
$(`<li>${value.name}</li>`).appendTo("#list");
})
})
</script>
<body>
<ol id="list">
</ol>
Example :
var data = [
Category : "Electronics",
},
309
https://github.com/karrasankar158
Category : "Shoes",
Answer :
<script>
var data = [
Category : "Electronics",
},
Category : "Shoes",
$(document).ready(function(){
$(`<li>${value.category}</li>`).appendTo("#list");
$.each(value.Products,function(key, value){
$(`<ul><li>${value}</li></ul>`).appendTo("#list");
})
310
https://github.com/karrasankar158
})
})
</script>
<body>
<ol id="list"></ol>
Exercise :
var products = [
];
//////////////////////////////////INCOMPLETE////////////////////////////////
311
https://github.com/karrasankar158
JQuery UI
1. JQuery provides a set of functions that are used to handle UI which includes a set
of effects, widgets and themes build on the top of JQuery JavaScript library.
A. Interactions
B. Widgets
C. Effects
D. Utilities
https://jqueryui.com/
6. Goto your project location and create new folder in “node_modules” by name
“jquery_ui”
Node_modules
Jquery_ui
Jquery-ui.js
312
https://github.com/karrasankar158
JQuery interactions :
JQuery provides a set of functions used for interactions which includes the
following,
A. Draggable
B. Droppable
C. Resizable
D. Selectable
E. Sortable
Example :
<head>
<style>
img {
cursor :move;
</style>
<script src="../node_modules/jquery/dist/jquery.js"></script>
<script src="../node_modules/jquery_ui/jquery-ui.js"></script>
<script>
$(document).ready(function(){
$("#pic").draggable();
$("#pic").resizable();
})
313
https://github.com/karrasankar158
</script>
<body>
</body>
JQuery Widgets :
i. Accordion
ii. Button
iii. Controlgroup
iv. Dialog
v. Progerssbar
vi. Slider
vii. Tabs
viii. Autocomplete
ix. Checkboxradio
x. Datepicker
xi. Menu
xii. Selectmenu
xiii. Spinner
xiv. Tooltip
314
https://github.com/karrasankar158
Example :
<head>
<script>
$(document).ready(function(){
$("#txtdate").datepicker();
})
</script>
</head>
<body>
<fieldset>
</fieldset>
</body>
JQuery Ajax
➢ Ajax allows to submit only a specific portion of page without reloading the
complete page.
315
https://github.com/karrasankar158
316