JavaScript Variable , Functions and CSS
- Variable is used to storing the data value.
- A variable is any characteristics, number, or quantity that can be measured or counted.
- A variable may also be called a data item.
- JavaScript support non variant variable.
- JavaScript dose not used data type.
- Types of variable :- a) Variant variable verify the data using the data type,e.g. int a b) Non variant variable dose not used any data type.It is depend on data value.It is used in JavaScript and Linux.e.g. a=10, a= 10.5,a=Ramesh.
- Create variable in JavaScript using var keyword.
- In user input variable, only declare the name of variable.
- In any programming language, default input will be string .
- example:- int a=10; document.write("The value of variable"+a);
Examples 1:-
<html>
<head>
<script Language="JavaScript">
var a=10;
document.write(a+"<br>");
document.write("The value of"+ " " +a);
</script>
</head>
</html>
output:- The value of variable 10
JavaScript Functions
Function is a small job program. the symbol ( ) defines function and it is called as function separator.
Types of functions are,
- User defined function(Intrinsic function)
- Builtin/library function( Extrinsic function):- It is pre defined function in computer memory.
How to create function
Using function keyword you can create any type of function.
Syntax:- function name( )
{
------------
------------
}
How to access function
All functions are to be access inside the button event. With help on event-onclick ,all the function can be accessible. for eg. onclick="function name ( )";
Function parameter
All type of data inside the function separator ( ) is called arguments. For eg. Display(10),here 10 is argument.
Example of getElementById
<html>
<head>
<script language="JavaScript">
function addition()
{
var a=parseInt(document.getElementById("txt1").value);
var b=parseInt(document.getElementById("txt2").value);
var c=parseInt(a+b);
document.getElementById("txt3").value=c;
}
</script>
</head>
<body>
Enter first number:- <input type="text" id=txt1><br>
Enter second number:-<input type="text" id=txt2><br>
Addition:-<input type="text" id=txt3><br>
<input type="button" value="submit" onclick="addition();">
</body>
</html>
How to display URL of web page (Inline Script)
Inline script is used to inside the body tag
<body>
<script>
</script>
</body>
JavaScript Window( )
It is used to open the separate browser
How to set height width window ( )
window.open("https://www.google.com","My window","height=400,width=400");
****CSS : cascading style sheets****
1.css is used to arranging the page
2.Css is used to create inside or outside HTML.
3.CSS cannot used tag <> symbol
****Types of CSS****
1.Internal
2.External
3.Inline
####Internal CSS####
Extenton of page: .html
###External CSS###
Extention of page: .CSS
###Inline####
CSS direct used with any HTML tags.
****How to create Internal CSS****
structure:
<html>
<head>
<style type="text/css">
create CSS
</style>
</head>
<body>
</body>
</html>
**** methods of css creation****
1.Using tagname method
syntax:
tagname
{
attribute;
}
NOTE: Dfference between HTML and CSS attributes
all html attribute used eual to(=) operator
eg.height=100 width=200
all css attribute used in colon(:) operator
eg. height:100
width:100
NOTE:tagname method cannot used similar tag name.
2.Using classname method
syntax:
.classname
{
attribute:value;
}
***HOW TO ACCESS CLASS INSIDE THE TAG***
access any type of class inside the tag using class attribute.
syntax:
<tagname class="classname">
eg.<font class="one">
***Cell creation***
1.cell is used to arranging the website contained
2.cell is used to create with the help of <div>......</div>
3.there are following attribute used in <div>
1.id
2.height
3.width
4.background- color
5.top
6.left
7.position[bydefault position is fixed(no change)]
NOTE:if change the all parameter using absolute position
CSS is work on pixel data value (px)
Comments
Post a Comment