Presentation is loading. Please wait.

Presentation is loading. Please wait.

Style properties in JavaScript

Similar presentations


Presentation on theme: "Style properties in JavaScript"— Presentation transcript:

1 Style properties in JavaScript
Inline code with window and Date object Passing query to Google Creating Functions Creating Array Selection Statement  if…else

2 Style properties in JavaScript
style.backgroundImage style.backgroundColor style.border style.margin style.padding style.filter style.visibility style.position style.top style.left style.color style.fontSize style.fontWeight style.width

3 Inline code with window and Date object
Inline code found between <script> and </script> tag. Inline code is invoked or executed when the browser gets up to the line of code <body> <script type=“text/javascript”> <!-- var name= window.prompt(“question”, “initial value”); var d = new Date(); var day= d.getDate(); //--> </script> </body>

4 Passing query to Google
Step 1: Create a text field. Assign a name to the field Step 2: Create a button. Using an event handler, send the text value to google.

5 Creating Functions Function contains a set of statements performing a single task Major advantage of having function is programmer’s ability to reuse Syntax:  function with no parameter function funName() { }  function with parameter function funName( para1, para2, etc) { }

6 Calling Functions A function has to be called in order to be executed. This can be done through event handler or inline technique Syntax //calling function with no parameter funName() // calling function with parameter funName(argument1, argument2, etc)

7 Creating Array Array object stores a list of values
Each value is an element of the Array and has an associated index Create array with initial values var arrayName = new Array(elment0, element1, element2, etc); Create array with size defined var arrayName = new Array(3); arrayName[0] = value; arrayName[1] = value; arrayName[2] = value;

8 Selection Statement Selection or conditional statements perform different actions based on different conditions If Statement Syntax if( condition ) Statement Semantics Evaluate the condition (true or false) If the condition is true True: DO STATEMENT False: SKIP the STATEMENT

9 Selection Statments Syntax: if…else if(condition)
{ if the condition is true, the code in here is executed} else { if the code is false, the code in here is executed}


Download ppt "Style properties in JavaScript"

Similar presentations


Ads by Google