jQuery is a fast and concise JavaScript library created by John Resig in 2006. jQuery simplifies HTML document traversing, event handling, animating, and Ajax interactions for Rapid Web Development.
jQuery &-8211; Questions & Answers &-8211; this Article or News was published on this date:2019-05-12 10:44:19 kindly share it with friends if you find it helpful
jQuery Questions and Answers has been designed with a special intention of helping students and professionals preparing for various Certification Exams and Job Interviews. This section provides a useful collection of sample Interview Questions and Multiple Choice Questions (MCQs) and their answers with appropriate explanations.
This section provides a huge collection of jQuery Interview Questions with their answers hidden in a box to challenge you to have a go at them before discovering the correct answer.
This section provides a great collection of jQuery Multiple Choice Questions (MCQs) on a single page along with their correct answers and explanation. If you select the right option, it turns green; else red.
If you are preparing to appear for a Java and jQuery Framework related certification exam, then this section is a must for you. This section simulates a real online test along with a given timer which challenges you to complete the test within a given time-frame. Finally you can check your overall test score and how you fared among millions of other candidates who attended this online test.
This section provides various mock tests that you can download at your local machine and solve offline. Every mock test is supplied with a mock test key to let you verify the final score and grade yourself.
jQuery &-8211; Quick Guide &-8211; this Article or News was published on this date:2019-05-12 10:44:19 kindly share it with friends if you find it helpful
jQuery is a fast and concise JavaScript Library created by John Resig in 2006 with a nice motto: Write less, do more. jQuery simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is a JavaScript toolkit designed to simplify various tasks by writing less code. Here is the list of important core features supported by jQuery −
DOM manipulation − The jQuery made it easy to select DOM elements, negotiate them and modifying their content by using cross-browser open source selector engine called Sizzle.
Event handling − The jQuery offers an elegant way to capture a wide variety of events, such as a user clicking on a link, without the need to clutter the HTML code itself with event handlers.
AJAX Support − The jQuery helps you a lot to develop a responsive and featurerich site using AJAX technology.
Animations − The jQuery comes with plenty of built-in animation effects which you can use in your websites.
Lightweight − The jQuery is very lightweight library &-8211; about 19KB in size (Minified and gzipped).
Cross Browser Support − The jQuery has cross-browser support, and works well in IE 6.0+, FF 2.0+, Safari 3.0+, Chrome and Opera 9.0+
Latest Technology − The jQuery supports CSS3 selectors and basic XPath syntax.
How to use jQuery?
There are two ways to use jQuery.
Local Installation − You can download jQuery library on your local machine and include it in your HTML code.
CDN Based Version − You can include jQuery library into your HTML code directly from Content Delivery Network (CDN).
You can include jQuery library into your HTML code directly from Content Delivery Network (CDN). Google and Microsoft provides content deliver for the latest version.
We are using Google CDN version of the library throughout this tutorial.
Example
Now let us rewrite above example using jQuery library from Google CDN.
As almost everything, we do when using jQuery reads or manipulates the document object model (DOM), we need to make sure that we start adding events etc. as soon as the DOM is ready.
If you want an event to work on your page, you should call it inside the $(document).ready() function. Everything inside it will load as soon as the DOM is loaded and before the page contents are loaded.
To do this, we register a ready event for the document as follows −
$(document).ready(function() {
// do stuff when DOM is ready
});
To call upon any jQuery library function, use HTML script tags as shown below −
</l>
head>
title>The jQuery Example/title>
script type = "text/javascript"
src = "https://ajax.googleapis.com/libs/jquery/2.1.3/jquery.min.js">
/script>
script type = "text/javascript" language = "javascript">
$(document).ready(function() {
$("div").click(function() {alert("Hello, world!");});
});
/script>
/head>
body>
div id = "mydiv">
Click on this to see a dialogue box.
/div>
/body>
/l>
This will produce following result −
How to Use Custom Scripts?
It is better to write our custom code in the custom JavaScript file : custom.js, as follows −
</l>
head>
title>The jQuery Example/title>
script type = "text/javascript"
src = "https://ajax.googleapis.com/libs/jquery/2.1.3/jquery.min.js">
/script>
script type = "text/javascript" src = "/jquery/custom.js">
/script>
/head>
body>
div id = "mydiv">
Click on this to see a dialogue box.
/div>
/body>
/l>
This will produce following result −
Using Multiple Libraries
You can use multiple libraries all together without conflicting each others. For example, you can use jQuery and MooTool javascript libraries together. You can check jQuery noConflict Method for more detail.
What is Next ?
Do not worry too much if you did not understand above examples. You are going to grasp them very soon in subsequent chapters.
Next chapter would try to cover few basic concepts which are coming from conventional JavaScript.
jQuery &-8211; Basics
jQuery is a framework built using JavaScript capabilities. So, you can use all the functions and other capabilities available in JavaScript. This chapter would explain most basic concepts but frequently used in jQuery.
String
A string in JavaScript is an immutable object that contains none, one or many characters. Following are the valid examples of a JavaScript String −
"This is JavaScript String"
'This is JavaScript String'
'This is "really" a JavaScript String'
"This is 'really' a JavaScript String"
Numbers
Numbers in JavaScript are double-precision 64-bit format IEEE 754 values. They are immutable, just as strings. Following are the valid examples of a JavaScript Numbers −
5350
120.27
0.26
Boolean
A boolean in JavaScript can be either true or false. If a number is zero, it defaults to false. If an empty string defaults to false.
Following are the valid examples of a JavaScript Boolean −
The arguments object also has a callee property, which refers to the function you&-8217;re inside of. For example −
function func() {
return arguments.callee;
}
func(); // ==> func
Context
JavaScript famous keyword this always refers to the current context. Within a function this context can change, depending on how the function is called −
$(document).ready(function() {
// this refers to window.document
});
$("div").click(function() {
// this refers to a div DOM element
});
You can specify the context for a function call using the function-built-in methods call() and apply() methods.
The difference between them is how they pass arguments. Call passes all arguments through as arguments to the function, while apply accepts an array as the arguments.
The scope of a variable is the region of your program in which it is defined. JavaScript variable will have only two scopes.
Global Variables − A global variable has global scope which means it is defined everywhere in your JavaScript code.
Local Variables − A local variable will be visible only within a function where it is defined. Function parameters are always local to that function.
Within the body of a function, a local variable takes precedence over a global variable with the same name −
var myVar = "global"; // ==> Declare a global variable
function ( ) {
var myVar = "local"; // ==> Declare a local variable
document.write(myVar); // ==> local
}
Callback
A callback is a plain JavaScript function passed to some method as an argument or option. Some callbacks are just events, called to give the user a chance to react when a certain state is triggered.
jQuery&-8217;s event system uses such callbacks everywhere for example −
Most callbacks provide arguments and a context. In the event-handler example, the callback is called with one argument, an Event.
Some callbacks are required to return something, others make that return value optional. To prevent a form submission, a submit event handler can return false as follows −
Closures are created whenever a variable that is defined outside the current scope is accessed from within some inner scope.
Following example shows how the variable counter is visible within the create, increment, and print functions, but not outside of them −
function create() {
var counter = 0;
return {
increment: function() {
counter++;
},
print: function() {
console.log(counter);
}
}
}
var c = create();
c.increment();
c.print(); // ==> 1
This pattern allows you to create objects with methods that operate on data that isn&-8217;t visible to the outside world. It should be noted that data hiding is the very basis of object-oriented programming.
Proxy Pattern
A proxy is an object that can be used to control access to another object. It implements the same interface as this other object and passes on any method invocations to it. This other object is often called the real subject.
A proxy can be instantiated in place of this real subject and allow it to be accessed remotely. We can saves jQuery&-8217;s setArray method in a closure and overwrites it as follows −
(function() {
// log all calls to setArray
var proxied = jQuery.fn.setArray;
jQuery.fn.setArray = function() {
console.log(this, arguments);
return proxied.apply(this, arguments);
};
})();
The above wraps its code in a function to hide the proxied variable. The proxy then logs all calls to the method and delegates the call to the original method. Using apply(this, arguments) guarantees that the caller won&-8217;t be able to notice the difference between the original and the proxied method.
Built-in Functions
JavaScript comes along with a useful set of built-in functions. These methods can be used to manipulate Strings, Numbers and Dates.
Following are important JavaScript functions −
Sr.No.
Method & Description
1
charAt()
Returns the character at the specified index.
2
concat()
Combines the text of two strings and returns a new string.
3
forEach()
Calls a function for each element in the array.
4
indexOf()
Returns the index within the calling String object of the first occurrence of the specified value, or -1 if not found.
5
length()
Returns the length of the string.
6
pop()
Removes the last element from an array and returns that element.
7
push()
Adds one or more elements to the end of an array and returns the new length of the array.
8
reverse()
Reverses the order of the elements of an array &-8212; the first becomes the last, and the last becomes the first.
9
sort()
Sorts the elements of an array.
10
substr()
Returns the characters in a string beginning at the specified location through the specified number of characters.
11
toLowerCase()
Returns the calling string value converted to lower case.
12
toString()
Returns the string representation of the number&-8217;s value.
13
toUpperCase()
Returns the calling string value converted to uppercase.
The Document Object Model
The Document Object Model is a tree structure of various elements of HTML as follows −
</l>
head>
title>The jQuery Example/title>
/head>
body>
div>
p>This is a paragraph./p>
p>This is second paragraph./p>
p>This is third paragraph./p>
/div>
/body>
/l>
This will produce following result −
Following are the important points about the above tree structure −
The </l> is the ancestor of all the other elements; in other words, all the other elements are descendants of </l>.
The head> and body> elements are not only descendants, but children of </l>, as well.
Likewise, in addition to being the ancestor of head> and body>, </l> is also their parent.
The p> elements are children (and descendants) of div>, descendants of body> and </l>, and siblings of each other p> elements.
While learning jQuery concepts, it will be helpful to have understanding on DOM, if you are not aware of DOM then I would suggest to go through our simple tutorial on DOM Tutorial.
jQuery &-8211; Selectors
The jQuery library harnesses the power of Cascading Style Sheets (CSS) selectors to let us quickly and easily access elements or groups of elements in the Document Object Model (DOM).
A jQuery Selector is a function which makes use of expressions to find out matching elements from a DOM based on the given criteria. Simply you can say, selectors are used to select one or more HTML elements using jQuery. Once an element is selected then we can perform various operations on that selected element.
The $() factory function
jQuery selectors start with the dollar sign and parentheses − $(). The factory function $() makes use of following three building blocks while selecting elements in a given document −
Sr.No.
Selector & Description
1
Tag Name
Represents a tag name available in the DOM. For example $(&-8216;p&-8217;) selects all paragraphs p> in the document.
2
Tag ID
Represents a tag available with the given ID in the DOM. For example $(&-8216;-some-id&-8217;) selects the single element in the document that has an ID of some-id.
3
Tag Class
Represents a tag available with the given class in the DOM. For example $(&-8216;.some-class&-8217;) selects all elements in the document that have a class of some-class.
All the above items can be used either on their own or in combination with other selectors. All the jQuery selectors are based on the same principle except some tweaking.
NOTE − The factory function $() is a synonym of jQuery() function. So in case you are using any other JavaScript library where $ sign is conflicting with some thing else then you can replace $ sign by jQuery name and you can use function jQuery() instead of $().
Example
Following is a simple example which makes use of Tag Selector. This would select all the elements with a tag name p.
</l>
head>
title>The jQuery Example/title>
script type = "text/javascript"
src = "https://ajax.googleapis.com/libs/jquery/2.1.3/jquery.min.js">
/script>
script type = "text/javascript" language = "javascript">
$(document).ready(function() {
$("p").css("background-color", "yellow");
});
/script>
/head>
body>
div>
p class = "myclass">This is a paragraph./p>
p id = "myid">This is second paragraph./p>
p>This is third paragraph./p>
/div>
/body>
/l>
This will produce following result −
How to Use Selectors?
The selectors are very useful and would be required at every step while using jQuery. They get the exact element that you want from your HTML document.
Following table lists down few basic selectors and explains them with examples.
Selects the combined results of all the specified selectors E, F or G.
Selectors Examples
Similar to above syntax and examples, following examples would give you understanding on using different type of other useful selectors −
Sr.No.
Selector & Description
1
$(&-8216;*&-8217;)
This selector selects all elements in the document.
2
$(&-8220;p > *&-8221;)
This selector selects all elements that are children of a paragraph element.
3
$(&-8220;-specialID&-8221;)
This selector function gets the element with id=&-8221;specialID&-8221;.
4
$(&-8220;.specialClass&-8221;)
This selector gets all the elements that have the class of specialClass.
5
$(&-8220;li:not(.myclass)&-8221;)
Selects all elements matched by li> that do not have class = &-8220;myclass&-8221;.
6
$(&-8220;a-specialID.specialClass&-8221;)
This selector matches links with an id of specialID and a class of specialClass.
7
$(&-8220;p a.specialClass&-8221;)
This selector matches links with a class of specialClass declared within p> elements.
8
$(&-8220;ul li:first&-8221;)
This selector gets only the first li> element of the ul>.
9
$(&-8220;-container p&-8221;)
Selects all elements matched by p> that are descendants of an element that has an id of container.
10
$(&-8220;li > ul&-8221;)
Selects all elements matched by ul> that are children of an element matched by li>
11
$(&-8220;strong + em&-8221;)
Selects all elements matched by em> that immediately follow a sibling element matched by strong>.
12
$(&-8220;p ~ ul&-8221;)
Selects all elements matched by ul> that follow a sibling element matched by p>.
13
$(&-8220;code, em, strong&-8221;)
Selects all elements matched by code> or em> or strong>.
14
$(&-8220;p strong, .myclass&-8221;)
Selects all elements matched by strong> that are descendants of an element matched by p> as well as all elements that have a class of myclass.
15
$(&-8220;:empty&-8221;)
Selects all elements that have no children.
16
$(&-8220;p:empty&-8221;)
Selects all elements matched by p> that have no children.
17
$(&-8220;div[p]&-8221;)
Selects all elements matched by div> that contain an element matched by p>.
18
$(&-8220;p[.myclass]&-8221;)
Selects all elements matched by p> that contain an element with a class of myclass.
19
$(&-8220;a[@rel]&-8221;)
Selects all elements matched by a> that have a rel attribute.
20
$(&-8220;input[@name = myname]&-8221;)
Selects all elements matched by input> that have a name value exactly equal to myname.
21
$(&-8220;input[@name^=myname]&-8221;)
Selects all elements matched by input> that have a name value beginning with myname.
22
$(&-8220;a[@rel$=self]&-8221;)
Selects all elements matched by a> that have rel attribute value ending with self.
23
$(&-8220;a[@href*=domain.com]&-8221;)
Selects all elements matched by a> that have an href value containing domain.com.
24
$(&-8220;li:even&-8221;)
Selects all elements matched by li> that have an even index value.
25
$(&-8220;tr:odd&-8221;)
Selects all elements matched by tr> that have an odd index value.
26
$(&-8220;li:first&-8221;)
Selects the first li> element.
27
$(&-8220;li:last&-8221;)
Selects the last li> element.
28
$(&-8220;li:visible&-8221;)
Selects all elements matched by li> that are visible.
29
$(&-8220;li:hidden&-8221;)
Selects all elements matched by li> that are hidden.
30
$(&-8220;:radio&-8221;)
Selects all radio buttons in the form.
31
$(&-8220;:checked&-8221;)
Selects all checked box in the form.
32
$(&-8220;:input&-8221;)
Selects only form elements (input, select, textarea, button).
33
$(&-8220;:text&-8221;)
Selects only text elements (input[type = text]).
34
$(&-8220;li:eq(2)&-8221;)
Selects the third li> element.
35
$(&-8220;li:eq(4)&-8221;)
Selects the fifth li> element.
36
$(&-8220;li:lt(2)&-8221;)
Selects all elements matched by li> element before the third one; in other words, the first two li> elements.
37
$(&-8220;p:lt(3)&-8221;)
selects all elements matched by p> elements before the fourth one; in other words the first three p> elements.
38
$(&-8220;li:gt(1)&-8221;)
Selects all elements matched by li> after the second one.
39
$(&-8220;p:gt(2)&-8221;)
Selects all elements matched by p> after the third one.
40
$(&-8220;div/p&-8221;)
Selects all elements matched by p> that are children of an element matched by div>.
41
$(&-8220;div//code&-8221;)
Selects all elements matched by code>that are descendants of an element matched by div>.
42
$(&-8220;//p//a&-8221;)
Selects all elements matched by a> that are descendants of an element matched by p>
43
$(&-8220;li:first-child&-8221;)
Selects all elements matched by li> that are the first child of their parent.
44
$(&-8220;li:last-child&-8221;)
Selects all elements matched by li> that are the last child of their parent.
45
$(&-8220;:parent&-8221;)
Selects all elements that are the parent of another element, including text.
46
$(&-8220;li:contains(second)&-8221;)
Selects all elements matched by li> that contain the text second.
You can use all the above selectors with any HTML/XML element in generic way. For example if selector $(&-8220;li:first&-8221;) works for li> element then $(&-8220;p:first&-8221;) would also work for p> element.
jQuery &-8211; Attributes
Some of the most basic components we can manipulate when it comes to DOM elements are the properties and attributes assigned to those elements.
Most of these attributes are available through JavaScript as DOM node properties. Some of the more common properties are −
className
tagName
id
href
title
rel
src
Consider the following HTML markup for an image element −
img id = "imageid" src = "image.gif" alt = "Image" class = "myclass"
title = "This is an image"/>
In this element&-8217;s markup, the tag name is img, and the markup for id, src, alt, class, and title represents the element&-8217;s attributes, each of which consists of a name and a value.
jQuery gives us the means to easily manipulate an element&-8217;s attributes and gives us access to the element so that we can also change its properties.
Get Attribute Value
The attr() method can be used to either fetch the value of an attribute from the first element in the matched set or set attribute values onto all matched elements.
Example
Following is a simple example which fetches title attribute of em> tag and set div id = &-8220;divid&-8221;> value with the same value −
</l>
head>
title>The jQuery Example/title>
script type = "text/javascript"
src = "https://ajax.googleapis.com/libs/jquery/2.1.3/jquery.min.js">
/script>
script type = "text/javascript" language = "javascript">
$(document).ready(function() {
var title = $("em").attr("title");
$("-divid").text(title);
});
/script>
/head>
body>
div>
em title = "Bold and Brave">This is first paragraph./em>
p id = "myid">This is second paragraph./p>
div id = "divid">/div>
/div>
/body>
/l>
This will produce following result −
Set Attribute Value
The attr(name, value) method can be used to set the named attribute onto all elements in the wrapped set using the passed value.
Example
Following is a simple example which set src attribute of an image tag to a correct location −
</l>
head>
title>The jQuery Example/title>
base href="https://schoolforum.me" />
script type = "text/javascript"
src = "https://ajax.googleapis.com/libs/jquery/2.1.3/jquery.min.js">
/script>
script type = "text/javascript" language = "javascript">
$(document).ready(function() {
$("-myimg").attr("src", "/jquery/images/jquery.jpg");
});
/script>
/head>
body>
div>
img id = "myimg" src = "/images/jquery.jpg" alt = "Sample image" />
/div>
/body>
/l>
This will produce following result −
Applying Styles
The addClass( classes ) method can be used to apply defined style sheets onto all the matched elements. You can specify multiple classes separated by space.
Example
Following is a simple example which sets class attribute of a para p> tag −
</l>
head>
title>The jQuery Example/title>
script type = "text/javascript"
src = "https://ajax.googleapis.com/libs/jquery/2.1.3/jquery.min.js">
/script>
script type = "text/javascript" language = "javascript">
$(document).ready(function() {
$("em").addClass("selected");
$("-myid").addClass("highlight");
});
/script>
style>
.selected { color:red; }
.highlight { background:yellow; }
/style>
/head>
body>
em title = "Bold and Brave">This is first paragraph./em>
p id = "myid">This is second paragraph./p>
/body>
/l>
This will produce following result −
Attribute Methods
Following table lists down few useful methods which you can use to manipulate attributes and properties −
Set the value attribute of every matched element if it is called on input> but if it is called on select> with the passed option> value then passed option would be selected, if it is called on check box or radio box then all the matching check box and radiobox would be checked.
Examples
Similar to above syntax and examples, following examples would give you understanding on using various attribute methods in different situation −
Sr.No.
Selector & Description
1
$(&-8220;-myID&-8221;).attr(&-8220;custom&-8221;)
This would return value of attribute custom for the first element matching with ID myID.
This would select Orange and Mango options in a dropdown box with options Orange, Mango and Banana.
jQuery &-8211; DOM Traversing
jQuery is a very powerful tool which provides a variety of DOM traversal methods to help us select elements in a document randomly as well as in sequential method. Most of the DOM Traversal Methods do not modify the jQuery object and they are used to filter out elements from a document based on given conditions.
Find Elements by Index
Consider a simple document with the following HTML content −
The filter( selector ) method can be used to filter out all elements from the set of matched elements that do not match the specified selector(s). The selector can be written using any selector syntax.
Example
Following is a simple example which applies color to the lists associated with middle class −
</l>
head>
title>The JQuery Example/title>
script type = "text/javascript"
src = "https://ajax.googleapis.com/libs/jquery/2.1.3/jquery.min.js">
/script>
script type = "text/javascript" language = "javascript">
$(document).ready(function() {
$("li").filter(".middle").addClass("selected");
});
/script>
style>
.selected { color:red; }
/style>
/head>
body>
div>
ul>
li class = "top">list item 1/li>
li class = "top">list item 2/li>
li class = "middle">list item 3/li>
li class = "middle">list item 4/li>
li class = "bottom">list item 5/li>
li class = "bottom">list item 6/li>
/ul>
/div>
/body>
/l>
This will produce following result −
Locating Descendant Elements
The find( selector ) method can be used to locate all the descendant elements of a particular type of elements. The selector can be written using any selector syntax.
Example
Following is an example which selects all the span> elements available inside different p> elements −
Get a set of elements containing all of the unique siblings of each of the matched set of elements.
jQuery &-8211; CSS Selectors Methods
The jQuery library supports nearly all of the selectors included in Cascading Style Sheet (CSS) specifications 1 through 3, as outlined on the World Wide Web Consortium&-8217;s site.
Using JQuery library developers can enhance their websites without worrying about browsers and their versions as long as the browsers have JavaScript enabled.
Most of the JQuery CSS Methods do not modify the content of the jQuery object and they are used to apply CSS properties on DOM elements.
Apply CSS Properties
This is very simple to apply any CSS property using JQuery method css( PropertyName, PropertyValue ).
Here is the syntax for the method −
selector.css( PropertyName, PropertyValue );
Here you can pass PropertyName as a javascript string and based on its value, PropertyValue could be string or integer.
Example
Following is an example which adds font color to the second list item.
You can apply multiple CSS properties using a single JQuery method CSS( {key1:val1, key2:val2&-8230;.). You can apply as many properties as you like in a single call.
Get the current computed, pixel, width of the first matched element.
jQuery &-8211; DOM Manipulation
JQuery provides methods to manipulate DOM in efficient way. You do not need to write big code to modify the value of any element&-8217;s attribute or to extract HTML code from a paragraph or division.
JQuery provides methods such as .attr(), /l(), and .val() which act as getters, retrieving information from DOM elements for later use.
Content Manipulation
The method gets the/l contents (innerHTML) of the first matched element.
Here is the syntax for the method −
selector/l( )
Example
Following is an example which makes use of /l() and .text(val) methods. Here /l() retrieves HTML content from the object and then .text( val ) method sets value of the object using passed parameter −
</l>
head>
title>The jQuery Example/title>
script type = "text/javascript"
src = "https://ajax.googleapis.com/libs/jquery/2.1.3/jquery.min.js">
/script>
script type = "text/javascript" language = "javascript">
$(document).ready(function() {
$("div").click(function () {
$(this).replaceWith("h1>JQuery is Great/h1>");
});
});
/script>
style>
-division{ margin:10px;padding:12px; border:2px solid -666; width:60px;}
/style>
/head>
body>
p>Click on the square below:/p>
span id = "result"> /span>
div id = "division" style = "background-color:blue;">
This is Blue Square!!
/div>
/body>
/l>
This will produce following result −
Removing DOM Elements
There may be a situation when you would like to remove one or more DOM elements from the document. JQuery provides two methods to handle the situation.
The empty( ) method remove all child nodes from the set of matched elements where as the method remove( expr ) method removes all matched elements from the DOM.
Here is the syntax for the method −
selector.remove( [ expr ])
or
selector.empty( )
You can pass optional parameter expr to filter the set of elements to be removed.
Example
Following is an example where elements are being removed as soon as they are clicked −
</l>
head>
title>The jQuery Example/title>
script type = "text/javascript"
src = "https://ajax.googleapis.com/libs/jquery/2.1.3/jquery.min.js">
/script>
script type = "text/javascript" language = "javascript">
$(document).ready(function() {
$("div").click(function () {
$(this).remove( );
});
});
/script>
style>
.div{ margin:10px;padding:12px; border:2px solid -666; width:60px;}
/style>
/head>
body>
p>Click on any square below:/p>
span id = "result"> /span>
div class = "div" style = "background-color:blue;">/div>
div class = "div" style = "background-color:green;">/div>
div class = "div" style = "background-color:red;">/div>
/body>
/l>
This will produce following result −
Inserting DOM Elements
There may be a situation when you would like to insert new one or more DOM elements in your existing document. JQuery provides various methods to insert elements at various locations.
The after( content ) method insert content after each of the matched elements where as the method before( content ) method inserts content before each of the matched elements.
Here is the syntax for the method −
selector.after( content )
or
selector.before( content )
Here content is what you want to insert. This could be HTML or simple text.
Example
Following is an example where div> elements are being inserted just before the clicked element −
Wrap the inner child contents of each matched element (including text nodes) with an HTML structure.
jQuery &-8211; Events Handling
We have the ability to create dynamic web pages by using events. Events are actions that can be detected by your Web Application.
Following are the examples events −
A mouse click
A web page loading
Taking mouse over an element
Submitting an HTML form
A keystroke on your keyboard, etc.
When these events are triggered, you can then use a custom function to do pretty much whatever you want with the event. These custom functions call Event Handlers.
Binding Event Handlers
Using the jQuery Event Model, we can establish event handlers on DOM elements with the bind() method as follows −
</l>
head>
title>The jQuery Example/title>
script type = "text/javascript"
src = "https://ajax.googleapis.com/libs/jquery/2.1.3/jquery.min.js">
/script>
script type = "text/javascript" language = "javascript">
$(document).ready(function() {
$('div').bind('click', function( event ){
alert('Hi there!');
});
});
/script>
style>
.div{ margin:10px;padding:12px; border:2px solid -666; width:60px;}
/style>
/head>
body>
p>Click on any square below to see the result:/p>
div class = "div" style = "background-color:blue;">ONE/div>
div class = "div" style = "background-color:green;">TWO/div>
div class = "div" style = "background-color:red;">THREE/div>
/body>
/l>
This code will cause the division element to respond to the click event; when a user clicks inside this division thereafter, the alert will be shown.
This will produce following result −
The full syntax of the bind() command is as follows −
selector.bind( eventType[, eventData], handler)
Following is the description of the parameters −
eventType − A string containing a JavaScript event type, such as click or submit. Refer to the next section for a complete list of event types.
eventData − This is optional parameter is a map of data that will be passed to the event handler.
handler − A function to execute each time the event is triggered.
Removing Event Handlers
Typically, once an event handler is established, it remains in effect for the remainder of the life of the page. There may be a need when you would like to remove event handler.
jQuery provides the unbind() command to remove an exiting event handler. The syntax of unbind() is as follows −
selector.unbind(eventType, handler)
or
selector.unbind(eventType)
Following is the description of the parameters −
eventType − A string containing a JavaScript event type, such as click or submit. Refer to the next section for a complete list of event types.
handler − If provided, identifies the specific listener that&-8217;s to be removed.
Event Types
Sr.No.
Event Type & Description
1
blur
Occurs when the element loses focus.
2
change
Occurs when the element changes.
3
click
Occurs when a mouse click.
4
dblclick
Occurs when a mouse double-click.
5
error
Occurs when there is an error in loading or unloading etc.
6
focus
Occurs when the element gets focus.
7
keydown
Occurs when key is pressed.
8
keypress
Occurs when key is pressed and released.
9
keyup
Occurs when key is released.
10
load
Occurs when document is loaded.
11
mousedown
Occurs when mouse button is pressed.
12
mouseenter
Occurs when mouse enters in an element region.
13
mouseleave
Occurs when mouse leaves an element region.
14
mousemove
Occurs when mouse pointer moves.
15
mouseout
Occurs when mouse pointer moves out of an element.
16
mouseover
Occurs when mouse pointer moves over an element.
17
mouseup
Occurs when mouse button is released.
18
resize
Occurs when window is resized.
19
scroll
Occurs when window is scrolled.
20
select
Occurs when a text is selected.
21
submit
Occurs when form is submitted.
22
unload
Occurs when documents is unloaded.
The Event Object
The callback function takes a single parameter; when the handler is called the JavaScript event object will be passed through it.
The event object is often unnecessary and the parameter is omitted, as sufficient context is usually available when the handler is bound to know exactly what needs to be done when the handler is triggered, however there are certain attributes which you would need to be accessed.
The Event Attributes
Sr.No.
Property & Description
1
altKey
Set to true if the Alt key was pressed when the event was triggered, false if not. The Alt key is labeled Option on most Mac keyboards.
2
ctrlKey
Set to true if the Ctrl key was pressed when the event was triggered, false if not.
3
data
The value, if any, passed as the second parameter to the bind() command when the handler was established.
4
keyCode
For keyup and keydown events, this returns the key that was pressed.
5
metaKey
Set to true if the Meta key was pressed when the event was triggered, false if not. The Meta key is the Ctrl key on PCs and the Command key on Macs.
6
pageX
For mouse events, specifies the horizontal coordinate of the event relative from the page origin.
7
pageY
For mouse events, specifies the vertical coordinate of the event relative from the page origin.
8
relatedTarget
For some mouse events, identifies the element that the cursor left or entered when the event was triggered.
9
screenX
For mouse events, specifies the horizontal coordinate of the event relative from the screen origin.
10
screenY
For mouse events, specifies the vertical coordinate of the event relative from the screen origin.
11
shiftKey
Set to true if the Shift key was pressed when the event was triggered, false if not.
12
target
Identifies the element for which the event was triggered.
13
timeStamp
The timestamp (in milliseconds) when the event was created.
14
type
For all events, specifies the type of event that was triggered (for example, click).
15
which
For keyboard events, specifies the numeric code for the key that caused the event, and for mouse events, specifies which button was pressed (1 for left, 2 for middle, 3 for right).
This does the opposite of bind, it removes bound events from each of the matched elements.
Event Helper Methods
jQuery also provides a set of event helper functions which can be used either to trigger an event to bind any event types mentioned above.
Trigger Methods
Following is an example which would triggers the blur event on all paragraphs −
$("p").blur();
Binding Methods
Following is an example which would bind a click event on all the div> −
$("div").click( function () {
// do something here
});
Sr.No.
Method & Description
1
blur( )
Triggers the blur event of each matched element.
2
blur( fn )
Bind a function to the blur event of each matched element.
3
change( )
Triggers the change event of each matched element.
4
change( fn )
Binds a function to the change event of each matched element.
5
click( )
Triggers the click event of each matched element.
6
click( fn )
Binds a function to the click event of each matched element.
7
dblclick( )
Triggers the dblclick event of each matched element.
8
dblclick( fn )
Binds a function to the dblclick event of each matched element.
9
error( )
Triggers the error event of each matched element.
10
error( fn )
Binds a function to the error event of each matched element.
11
focus( )
Triggers the focus event of each matched element.
12
focus( fn )
Binds a function to the focus event of each matched element.
13
keydown( )
Triggers the keydown event of each matched element.
14
keydown( fn )
Bind a function to the keydown event of each matched element.
15
keypress( )
Triggers the keypress event of each matched element.
16
keypress( fn )
Binds a function to the keypress event of each matched element.
17
keyup( )
Triggers the keyup event of each matched element.
18
keyup( fn )
Bind a function to the keyup event of each matched element.
19
load( fn )
Binds a function to the load event of each matched element.
20
mousedown( fn )
Binds a function to the mousedown event of each matched element.
21
mouseenter( fn )
Bind a function to the mouseenter event of each matched element.
22
mouseleave( fn )
Bind a function to the mouseleave event of each matched element.
23
mousemove( fn )
Bind a function to the mousemove event of each matched element.
24
mouseout( fn )
Bind a function to the mouseout event of each matched element.
25
mouseover( fn )
Bind a function to the mouseover event of each matched element.
26
mouseup( fn )
Bind a function to the mouseup event of each matched element.
27
resize( fn )
Bind a function to the resize event of each matched element.
28
scroll( fn )
Bind a function to the scroll event of each matched element.
29
select( )
Trigger the select event of each matched element.
30
select( fn )
Bind a function to the select event of each matched element.
31
submit( )
Trigger the submit event of each matched element.
32
submit( fn )
Bind a function to the submit event of each matched element.
33
unload( fn )
Binds a function to the unload event of each matched element.
jQuery &-8211; Ajax
AJAX is an acronym standing for Asynchronous JavaScript and XML and this technology helps us to load data from the server without a browser page refresh.
If you are new with AJAX, I would recommend you go through our Ajax Tutorial before proceeding further.
JQuery is a great tool which provides a rich set of AJAX methods to develop next generation web application.
Loading Simple Data
This is very easy to load any static or dynamic data using JQuery AJAX. JQuery provides load() method to do the job −
Syntax
Here is the simple syntax for load() method −
[selector].load( URL, [data], [callback] );
Here is the description of all the parameters −
URL − The URL of the server-side resource to which the request is sent. It could be a CGI, ASP, JSP, or PHP script which generates data dynamically or out of a database.
data − This optional parameter represents an object whose properties are serialized into properly encoded parameters to be passed to the request. If specified, the request is made using the POST method. If omitted, the GET method is used.
callback − A callback function invoked after the response data has been loaded into the elements of the matched set. The first parameter passed to this function is the response text received from the server and second parameter is the status code.
Example
Consider the following HTML file with a small JQuery coding −
</l>
head>
title>The jQuery Example/title>
script type = "text/javascript"
src = "https://ajax.googleapis.com/libs/jquery/2.1.3/jquery.min.js">
/script>
script type = "text/javascript" language = "javascript">
$(document).ready(function() {
$("-driver").click(function(event){
$('-stage').load('/jquery/result/l');
});
});
/script>
/head>
body>
p>Click on the button to load /jquery/result/l file −/p>
div id = "stage" style = "background-color:cc0;">
STAGE
/div>
input type = "button" id = "driver" value = "Load Data" />
/body>
/l>
Here load() initiates an Ajax request to the specified URL /jquery/result/l file. After loading this file, all the content would be populated inside div> tagged with ID stage. Assuming, our /jquery/result/l file has just one HTML line −
h1>THIS IS RESULT.../h1>
When you click the given button, then result/l file gets loaded.
Getting JSON Data
There would be a situation when server would return JSON string against your request. JQuery utility function getJSON() parses the returned JSON string and makes the resulting string available to the callback function as first parameter to take further action.
Syntax
Here is the simple syntax for getJSON() method −
[selector].getJSON( URL, [data], [callback] );
Here is the description of all the parameters −
URL − The URL of the server-side resource contacted via the GET method.
data − An object whose properties serve as the name/value pairs used to construct a query string to be appended to the URL, or a preformatted and encoded query string.
callback − A function invoked when the request completes. The data value resulting from digesting the response body as a JSON string is passed as the first parameter to this callback, and the status as the second.
Example
Consider the following HTML file with a small JQuery coding −
</l>
head>
title>The jQuery Example/title>
script type = "text/javascript"
src = "https://ajax.googleapis.com/libs/jquery/2.1.3/jquery.min.js">
/script>
script type = "text/javascript" language = "javascript">
$(document).ready(function() {
$("-driver").click(function(event){
$.getJSON('/jquery/result.json', function(jd) {
$('-stage')/l('p> Name: ' + jd.name + '/p>');
$('-stage').append('p>Age : ' + jd.age+ '/p>');
$('-stage').append('p> Sex: ' + jd.sex+ '/p>');
});
});
});
/script>
/head>
body>
p>Click on the button to load result.json file −/p>
div id = "stage" style = "background-color:-eee;">
STAGE
/div>
input type = "button" id = "driver" value = "Load Data" />
/body>
/l>
Here JQuery utility method getJSON() initiates an Ajax request to the specified URL result.json file. After loading this file, all the content would be passed to the callback function which finally would be populated inside div> tagged with ID stage. Assuming, our result.json file has following json formatted content −
When you click the given button, then result.json file gets loaded.
Passing Data to the Server
Many times you collect input from the user and you pass that input to the server for further processing. JQuery AJAX made it easy enough to pass collected data to the server using data parameter of any available Ajax method.
Example
This example demonstrate how can pass user input to a web server script which would send the same result back and we would print it −
</l>
head>
title>The jQuery Example/title>
script type = "text/javascript"
src = "https://ajax.googleapis.com/libs/jquery/2.1.3/jquery.min.js">
/script>
script type = "text/javascript" language = "javascript">
$(document).ready(function() {
$("-driver").click(function(event){
var name = $("-name").val();
$("-stage").load('/jquery/result.php', {"name":name} );
});
});
/script>
/head>
body>
p>Enter your name and click on the button:/p>
input type = "input" id = "name" size = "40" />br />
div id = "stage" style = "background-color:cc0;">
STAGE
/div>
input type = "button" id = "driver" value = "Show Result" />
/body>
/l>
Now you can enter any text in the given input box and then click &-8220;Show Result&-8221; button to see what you have entered in the input box.
JQuery AJAX Methods
You have seen basic concept of AJAX using JQuery. Following table lists down all important JQuery AJAX methods which you can use based your programming need −
Attach a function to be executed whenever an AJAX request completes successfully.
jQuery &-8211; Effects
jQuery provides a trivially simple interface for doing various kind of amazing effects. jQuery methods allow us to quickly apply commonly used effects with a minimum configuration. This tutorial covers all the important jQuery methods to create visual effects.
Showing and Hiding Elements
The commands for showing and hiding elements are pretty much what we would expect − show() to show the elements in a wrapped set and hide() to hide them.
Syntax
Here is the simple syntax for show() method −
[selector].show( speed, [callback] );
Here is the description of all the parameters −
speed − A string representing one of the three predefined speeds (&-8220;slow&-8221;, &-8220;normal&-8221;, or &-8220;fast&-8221;) or the number of milliseconds to run the animation (e.g. 1000).
callback − This optional parameter represents a function to be executed whenever the animation completes; executes once for each element animated against.
Following is the simple syntax for hide() method −
[selector].hide( speed, [callback] );
Here is the description of all the parameters −
speed − A string representing one of the three predefined speeds (&-8220;slow&-8221;, &-8220;normal&-8221;, or &-8220;fast&-8221;) or the number of milliseconds to run the animation (e.g. 1000).
callback − This optional parameter represents a function to be executed whenever the animation completes; executes once for each element animated against.
Example
Consider the following HTML file with a small JQuery coding −
</l>
head>
title>The jQuery Example/title>
script type = "text/javascript"
src = "https://ajax.googleapis.com/libs/jquery/2.1.3/jquery.min.js">
/script>
script type = "text/javascript" language = "javascript">
$(document).ready(function() {
$("-show").click(function () {
$(".mydiv").show( 1000 );
});
$("-hide").click(function () {
$(".mydiv").hide( 1000 );
});
});
/script>
style>
.mydiv{
margin:10px;
padding:12px;
border:2px solid -666;
width:100px;
height:100px;
}
/style>
/head>
body>
div class = "mydiv">
This is a SQUARE
/div>
input id = "hide" type = "button" value = "Hide" />
input id = "show" type = "button" value = "Show" />
/body>
/l>
This will produce following result −
Toggling the Elements
jQuery provides methods to toggle the display state of elements between revealed or hidden. If the element is initially displayed, it will be hidden; if hidden, it will be shown.
Syntax
Here is the simple syntax for one of the toggle() methods −
[selector]..toggle([speed][, callback]);
Here is the description of all the parameters −
speed − A string representing one of the three predefined speeds (&-8220;slow&-8221;, &-8220;normal&-8221;, or &-8220;fast&-8221;) or the number of milliseconds to run the animation (e.g. 1000).
callback − This optional parameter represents a function to be executed whenever the animation completes; executes once for each element animated against.
Example
We can animate any element, such as a simple div> containing an image −
Fade out all matched elements by adjusting their opacity to 0, then setting display to &-8220;none&-8221; and firing an optional callback after completion.
To use these effects you can either download latest jQuery UI Library jquery-ui-1.11.4.custom.zip from jQuery UI Library or use Google CDN to use it in the similar way as we have done for jQuery.
We have used Google CDN for jQuery UI using following code snippet in the HTML page so we can use jQuery UI −
Interactions could be added basic mouse-based behaviours to any element. Using with interactions, We can create sortable lists, resizeable elements, drag & drop behaviours.Interactions also make great building blocks for more complex widgets and applications.
a jQuery UI widget is a specialized jQuery plug-in.Using plug-in, we can apply behaviours to the elements. However, plug-ins lack some built-in capabilities, such as a way to associate data with its elements, expose methods, merge options with defaults, and control the plug-in&-8217;s lifetime.
!DOCTYPE/l>
</l>
head>
meta name = "viewport" content = "width = device-width, initial-scale = 1">
link rel = "stylesheet"
href = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
script src = "https://code.jquery.com/jquery-1.11.3.min.js">
/script>
script src = "https://code.jquery.com/jquery-1.11.3.min.js">
/script>
script
src = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js">
/script>
/head>
body>
div data-role = "page" id = "pageone" data-theme = "b">
div data-role = "header">
h1>Tutorials Point/h1>
/div>
div data-role = "main" class = "ui-content">
p>Text link/p>
a href = "-">A Standard Text Link/a>
a href = "-" class = "ui-btn">Link Button/a>
p>A List View:/p>
ul data-role = "listview" data-autodividers = "true" data-inset = "true">
li>a href = "-">Android /a>/li>
li>a href = "-">IOS/a>/li>
/ul>
label for = "fullname">Input Field:/label>
input type = "text" name = "fullname" id = "fullname"
placeholder = "Name..">
label for = "switch">Toggle Switch:/label>
select name = "switch" id = "switch" data-role = "slider">
option value = "on">On/option>
option value = "off" selected>Off/option>
/select>
/div>
div data-role = "footer">
h1>Tutorials point/h1>
/div>
/div>
/body>
/l>
This should produce following result −
jQuery &-8211; Utilities
Jquery provides serveral utilities in the formate of $(name space). These methods are helpful to complete the programming tasks.a few of the utility methods are as show below.
$.trim()
$.trim() is used to Removes leading and trailing whitespace
$.trim( " lots of extra whitespace " );
$.each()
$.each() is used to Iterates over arrays and objects
$.each([ "foo", "bar", "baz" ], function( idx, val ) {
console.log( "element " + idx + " is " + val );
});
$.each({ foo: "bar", baz: "bim" }, function( k, v ) {
console.log( k + " : " + v );
});
.each() can be called on a selection to iterate over the elements contained in the selection. .each(), not $.each(), should be used for iterating over elements in a selection.
$.inArray()
$.inArray() is used to Returns a value&-8217;s index in an array, or -1 if the value is not in the array.
$.extend() is used to Changes the properties of the first object using the properties of subsequent objects.
var firstObject = { foo: "bar", a: "b" };
var secondObject = { foo: "baz" };
var newObject = $.extend( firstObject, secondObject );
console.log( firstObject.foo );
console.log( newObject.foo );
$.proxy()
$.proxy() is used to Returns a function that will always run in the provided scope — that is, sets the meaning of this inside the passed function to the second argument
var myFunction = function() {
console.log( this );
};
var myObject = {
foo: "bar"
};
myFunction(); // window
var myProxyFunction = $.proxy( myFunction, myObject );
myProxyFunction();
$.browser
$.browser is used to give the information about browsers
jQuery.each( jQuery.browser, function( i, val ) {
$( "div>" + i + " : span>" + val + "/span>" )
.appendTo( document.body );
});
$.contains()
$.contains() is used to returns true if the DOM element provided by the second argument is a descendant of the DOM element provided by the first argument, whether it is a direct child or nested more deeply.
jQuery &-8211; Useful Resources &-8211; this Article or News was published on this date:2019-05-12 10:44:19 kindly share it with friends if you find it helpful
jQuery @ wiki &-8211; jQuery at Wikipedia, the free encyclopedia
ECMAScript &-8211; Official website for ECMAScript which is mothe of JavaScript and grandmother of jQuery.
Other JavaScript Frameworks
Prototype &-8211; This holds the reference API documentation, replete with examples and crossreferences. You&-8217;ll also find various tutorials and get to know Prototype Core members.
script.aculo.us &-8211; A complete set of reference API documentation, Installation Scripts.
DoJo &-8211; A complete set of reference API documentation, Installation Scripts.
Ext JS &-8211; A complete set of reference API documentation, Installation Scripts.
Rico &-8211; A complete set of reference API documentation, Installation Scripts.
Qooxdoo &-8211; qooxdoo is a comprehensive and innovative Ajax application framework.
Useful Books on jQuery
To enlist your site on this page, please drop an email to [email protected]
jQuery &-8211; Megadropdown.js &-8211; this Article or News was published on this date:2019-05-12 10:44:18 kindly share it with friends if you find it helpful
Megadropdown.js is a jQuery plugin for easy and quickly implementing of drop down menu.
Example of Drop down menu as shown below −
!doctype/l>
</l lang = "en" class = "no-js">
head>
meta charset = "UTF-8">
meta name = "viewport" content = "width = device-width, initial-scale = 1">
link rel = "stylesheet" href = "css/reset.css">
link rel = "stylesheet" href = "css/style.css">
script src = "js/modernizr.js">/script>
/head>
body>
header>
div class = "cd-dropdown-wrapper">
a class = "cd-dropdown-trigger" href = "-0">Dropdown/a>
nav class = "cd-dropdown">
h2>Title/h2>
a href = "-0" class = "cd-close">Close/a>
ul class = "cd-dropdown-content">
li>
form class = "cd-search">
input type = "search" placeholder = "Search...">
/form>
/li>
li class = "has-children">
a href = "">images/a>
ul class = "cd-dropdown-gallery is-hidden">
li class = "go-back">a href = "-0">Menu
/a>/li>
li class = "see-all">a href = "">
Browse Gallery/a>/li>
li>
a class = "cd-dropdown-item" href = "">
img src = "img/img.png" alt = "Product Image">
h3>Product -1/h3>
/a>
/li>
li>
a class = "cd-dropdown-item" href = "">
img src = "img/img.png" alt = "Product Image">
h3>Product -2/h3>
/a>
/li>
li>
a class = "cd-dropdown-item" href = "">
img src = "img/img.png" alt = "Product Image">
h3>Product -3/h3>
/a>
/li>
li>
a class = "cd-dropdown-item" href = "">
img src = "img/img.png" alt = "Product Image">
h3>Product -4/h3>
/a>
/li>
/ul>
/li>
li class = "has-children">
a href = "">Services/a>
ul class = "cd-dropdown-icons is-hidden">
li class = "go-back">a href = "-0">Menu
/a>/li>
li class = "see-all">a href = "">
Browse Services/a>/li>
li>
a class = "cd-dropdown-item item-1" href = "">
h3>Service -1/h3>
p>This is the item description/p>
/a>
/li>
li>
a class = "cd-dropdown-item item-2" href = "">
h3>Service -2/h3>
p>This is the item description/p>
/a>
/li>
li>
a class = "cd-dropdown-item item-3" href = "">
h3>Service -3/h3>
p>This is the item description/p>
/a>
/li>
li>
a class = "cd-dropdown-item item-4" href = "">
h3>Service -4/h3>
p>This is the item description/p>
/a>
/li>
li>
a class = "cd-dropdown-item item-5" href = "">
h3>Service -5/h3>
p>This is the item description/p>
/a>
/li>
li>
a class = "cd-dropdown-item item-6" href = "">
h3>Service -6/h3>
p>This is the item description/p>
/a>
/li>
li>
a class = "cd-dropdown-item item-7" href = "">
h3>Service -7/h3>
p>This is the item description/p>
/a>
/li>
li>
a class = "cd-dropdown-item item-8" href = "">
h3>Service -8/h3>
p>This is the item description/p>
/a>
/li>
li>
a class = "cd-dropdown-item item-9" href = "">
h3>Service -9/h3>
p>This is the item description/p>
/a>
/li>
li>
a class = "cd-dropdown-item item-10" href = "">
h3>Service -10/h3>
p>This is the item description/p>
/a>
/li>
li>
a class = "cd-dropdown-item item-11" href = "">
h3>Service -11/h3>
p>This is the item description/p>
/a>
/li>
li>
a class = "cd-dropdown-item item-12" href = "">
h3>Service -12/h3>
p>This is the item description/p>
/a>
/li>
/ul>
/li>
li class = "cd-divider">Divider/li>
li>a href = "">Page 1/a>/li>
li>a href = "">Page 2/a>/li>
li>a href = "">Page 3/a>/li>
/ul>
/nav>
/div>
/header>
main class = "cd-main-content">/main>
script src = "js/jquery-2.1.1.js">/script>
script src = "js/jquery.menu-aim.js">/script>
script src = "js/main.js">/script>
/body>
/l>