Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

JavaScript QuickStart: Elements of JavaScript : Page 3

JavaScript is cropping up everywhere and if you want to learn to use it, you'll need to understand these essential elements.


advertisement
Operators
Operators are mathematical verbs. They set, calculate, compare, or evaluate values. For example, if you want to assign a value to a variable, you would use the equal sign operator, like this:
fred = 100
This sets the variable "visits" to equal the variable "clicks" multipled by 2.
visits = clicks * 2
This compares the value of the variable "current" to see if it greater than or equal to 100.

current >= 100

Events
Remember, JavaScript was designed to work with a browser. It is "aware" of actions that happen inside the browser window, actions that the reader might do. These interactions between reader and browser are called events.



Some common events include:

  • mouseover: the reader putting the cursor over a link

  • mouseout: the reader removing the cursor from a link

  • click: the reader clicking on an option

  • submit: the reader submitting a form for processing.

Event Handlers
You can use JavaScript to make different things happen when a specified event occurs. You do this with a category of JavaScript elements called event handlers.

Event handlers are the glue that let you create an action tied to an event and make your site respond to what the reader does. Some event handlers are built into JavaScript. In addition, you can create your own event handlers for your specific applications.

Some common event handlers include:

  • onmouseover: when the reader puts the cursor over a link

  • onmouseout: when the reader removes the cursor from a link

  • onclick: when the reader clicks on an option

  • onsubmit: when the reader submits a form for processing.




Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date