Difference between revisions of "JQuery"
(9 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
− | jQuery is a | + | '''jQuery''' is a [[JavaScript]] library that simplifies [[HTML]] document traversing, event handling, animating, and [[AJAX]] interactions. |
+ | |||
+ | ==Example== | ||
+ | Here is an example piece of code written in jQuery: | ||
+ | |||
+ | <nowiki>$('div.container').html('hello world');</nowiki> | ||
+ | |||
+ | <b>$('div.container')</b> | ||
+ | |||
+ | This is a selector which is selecting all <b>div</b>'s with the class name <b>container</b>. The period (<b>.</b>) that detonates them means that you want to select the div with the class name <b>container</b>. You can use as hash mark (<b>#</b>) to select the div containing the <b>id</b> container as well. | ||
+ | |||
+ | <b>.html('hello world')</b> | ||
+ | |||
+ | Because you have selected your element, now you will have to do something with it. In this case, you would be using the html function. Every function takes in different parameters to utilize different functionalities; in this case, if you specify a first argument for the html function ('hello world'), you will <b>change the contents of the inner HTML</b> of the selected element. If you wanted to just get the contents of the inner HTML (the data between the <div> tags), you would simply call the html function without any arguments. | ||
+ | |||
+ | |||
+ | == External Links == | ||
+ | |||
+ | * [http://jquery.com/ jQuery Homepage] | ||
+ | |||
+ | {{programming}}{{social}} |
Latest revision as of 10:07, 2 May 2012
jQuery is a JavaScript library that simplifies HTML document traversing, event handling, animating, and AJAX interactions.
Example
Here is an example piece of code written in jQuery:
$('div.container').html('hello world');
$('div.container')
This is a selector which is selecting all div's with the class name container. The period (.) that detonates them means that you want to select the div with the class name container. You can use as hash mark (#) to select the div containing the id container as well.
.html('hello world')
Because you have selected your element, now you will have to do something with it. In this case, you would be using the html function. Every function takes in different parameters to utilize different functionalities; in this case, if you specify a first argument for the html function ('hello world'), you will change the contents of the inner HTML of the selected element. If you wanted to just get the contents of the inner HTML (the data between the <div> tags), you would simply call the html function without any arguments.