Apparel Software

Java Script Programming for Wordpress Part1

Java Script Programming 

Class Date : 03/04/17

Java Script

  • Java script is designed make interactive in HTML pages which is language of scripting.
  • Java script code is embedder directly to HTML pages.
  • Anybody can use java script without purchasing javbascript.
  • It can change HTML contents.
  • Java Scripts could be placed in the <body> sectin or in the <head> section of an HTML page or in both.

Types of Java Script Code

  • Java script code is three types which is listed below
  • External
  • Internal or Embedded
  • Inline /Div

Java Script Statement Syntax


Basic Syntex: <!doctype html>

<html> <body>

<script type="text/javascript">

document.write("<h1>Helo Babu? Are you learnig javascript form new horizon</h1>");

document.write("<h2>Helo Babu? Are you learnig java script form new horizon learning center</h2>");

document.write("<strong>Helo Babu? Are you learnig java script form new horizon</strong>");

document.write("Helo Babu? Are you learnig java script form new horizon");

</script>


</body> </html>


Java Script Comment


There are two type of comments is used in java script

Single Line Comments /* This is single line comments of javascript*/

Multi line comments /*This is multiline comments of java script. This is multiline comments of java script . This is multiline comments of java script */


External CSS and HTML Code

External Java Script


// JavaScript Document

function popup()

{alert("Helo New Horizon World");}


HTML Code

<!doctype html>

<html>

<head>

<meta charset="utf-8">

<title>HTML and Java Script Code</title>

<script src="myjs.js.js"></script>


</head>


<body>

<input type="button" onClick="popup()" value="Click Me New Horizon">


</body>

</html>

Result of above code :  Click Me New Horizon

JavaScript Operators



Java Script Variable

Generally variable is used to store data. İt contain information

Eg. Var x =5; and var country=”Bangladesh”;


Example 3

<!doctype html>

<html>

<head>

<meta charset="utf-8">

<title>Untitled Document</title>

</head>


<body>

<script type="text/javascript">

var x;

x=1978+1979;

document.write(x);

</script>


</body>

</html>

Result of above Code: 3957


Example 4

<script type="text/javascript">

x=5;

y=78;

z=x+y;

document.write(z);

</script>

Result of above code: 83

Example 4 (External Java Script and HTML)


External Java Script


// JavaScript Document

<script>

alert("Hellow Babylon World")

</script>

HTML Code

<html>

<head>

<meta charset="utf-8">

<title>Untitled Document</title>

<script src="js/popup.js"></script>

</head>


<body>

<script type="text/javascript">

x=3;

y=20*x+25;

alert(y);

</script>


</body>

</html>




Java Script If Statement

<!doctype html>

<html>

<head>

<meta charset="utf-8">

<title>Untitled Document</title>

</head>

<body>

<script type="text/javascript">

var mynewhorizon = 10;

if(mynewhorizon==8)

{

document.write("New Horizn you are lucky");

}

else{

document.write("Hellow New Horozon you are not lucky");

}

</script>

</body>

</html>

Result of Java Script If Statement

Hellow New Horozon you are not lucky


Java Script For Loop


<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>

</head>

<body>

<script type="text/javascript">

var ibabylon=0;

for(ibabylon=0;ibabylon<=5;ibabylon++)

{

document.write(" This number is for babylon group" +ibabylon);

document.wirte("<br/>");

}

</script>

</body>

</html>

Java Script For Loop Result: 

 This number is for babylon group0



Share :

Facebook Twitter Google+
0 Komentar untuk "Java Script Programming for Wordpress Part1"

Back To Top