N00Blog


JQuery
July 14, 2008, 6:15 am
Filed under: Web Applications | Tags: , , , , , ,

JQuery is a Javascript library which aims to simplify the use of javascript within html and make it more efficient. it is able to perform actions with one line of code which would normally take numerous lines of javascript.

Minifying is the automated process of minimizing the number of characters used in each action to the smallest amount, then used by JQuery. The resulting code will have the same functionality as the previous code, but load and run faster, and is often easier to understand.

JQuery has an inbuilt function :

$(document).ready(function(){ // Your code here });

which allows scripts to be run after the page has been loaded. In regular javascript, this type of action would require use of the onload attribute, often within the body tag. While this would require multiple lines of code, the built in ready function needs only one.

another useful part of JQuery is its chainability, meaning that actions previously spanning lines of code may be seperated by full stops in order to have each action follow on from one another.eg:

$(“p.surprise”).addClass(“ohMy”).show(“Slow”);

first finds any paragraphs named “surprise”, then adds a class to these called “ohMy”, and finally displays the content slowly

 $("a").click(function(event){   event.preventDefault();   $(this).hide("slow"); });

with this code, as far as i can tell, it works when the specified link is clicked on. It stops the link performing the default action (opening the location), and instead hide the link slowly.


No Comments Yet so far
Leave a comment



Leave a comment
Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>