Questions about this topic? Sign up to ask in the talk tab.

Difference between revisions of "JQuery"

From NetSec
Jump to: navigation, search
(Example)
Line 13: Line 13:
 
<b>.html('hello world')</b>
 
<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.
+
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.

Revision as of 08:41, 5 September 2011

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.