External JavaScript Code

External JavaScript code is placed inside an external JavaScript file.  This external JavaScript file contains a lengthy JavaScript code.  If you place same lengthy code inside a HTML file, it will make your whole code file look ugly.  It’s a good habit to place all lengthy code inside an external JavaScript file and add path

Inline JavaScript Code

Any JavaScript code, which is placed directly within a HTML file, is called Inline JavaScript code.  Inline JavaScript code should not be lengthy.  It should be a little piece of JavaScript code.  Example of Inline JavaScript code is given below. <html> <head> <title>JavaScript Tutorial </title> </head> <body> <script type="text/javascript"> alert("Hello World"); </script> </body> </html>  

How To Remove CSS Class Using jQuery

To remove CSS class using jQuery, you only need to use removeClass method.  In the sample code given below, we are removing CSS class myStyle from DIV element using function divClass(). <!DOCTYPE html> <html> <head> <title>jQuery Tutorial </title> <script src="http://code.jquery.com/jquery-latest.js"></script> <!-- CSS Class --> <style type="text/css"> .myStyle { background-color:red; color:white; font-weight: bold; } </style> <!--

How To Add CSS Class Using jQuery

To add CSS class using jQuery, you only need to use addClass method.  In the sample code given below, we are adding CSS class myStyle to a DIV element using function divClass(). <!DOCTYPE html> <html> <head> <title>jQuery Tutorial </title> <script src="http://code.jquery.com/jquery-latest.js"></script> <!-- CSS Class --> <style type="text/css"> .myStyle { background-color:red; color:white; font-weight: bold; } </style>

Selectors in jQuery

As we know, jQuery is mainly used to manipulate HTML elements in DOM.  The jQuery selectors play an important role in such manipulation.  Selectors help you in selecting right HTML element for manipulation.  You can add event handlers, styles, change attribute values of any HTML element etc. Some of the most common jQuery selectors are