JQuery : Learning basics Part 1

Code sample that will help you jump start JQuery. This is Part 1 of 2 part series.

var s=document.createElement('script');
s.setAttribute('src'
,'//ajax.googleapis.com/
ajax/libs/jquery/1.6.4/
jquery.min.js');

document.getElementsByTagName('body')[0].appendChild(s);

//CSS
$("#image40").height();
$("#image40").height(200);
$(".js").scrollTop(0);  
-- scroll the page or
the element to top,
adding zero is very important
$(".js").scrollLeft(20);
$("#image40").position();
$("#image40").outerHeight();
$("#image40").outerWidth();
$("#image40").width();

//EVENTS
function(event){
     alert("Thanks for visiting!");
   }
$("a").keypress(function(<wbr />event){
    alert("keypress");
event.preventDefault();
  });
$("a").focusin(function(event)<wbr />{
    alert("focusin");
event.preventDefault();
  });

$.browser.version
$.browser

$("div").delegate("a",
"hover", function(){
 alert('Example of Delegate!!');
});
$("div").undelegate();

//Hierarchy
$(".comment-body > .reply")
$(".comment-body .reply")

//Basic Filter
$(".comment-body > .reply")
.filter(":even")
$(".comment-body > .reply")
.filter(":odd")
$(".comment-body > .reply")
.filter(":odd").<wbr />filter(":first")
$(".comment-body > .reply")
.filter(":odd").<wbr />filter(":last")
$(".comment-body > .reply")
.filter(":odd").<wbr />filter(":gt(8)")  
//get thelist from 8th position
//i.e greter than 8
$(".comment-body > .reply").filter(":odd")
.<wbr />filter(":lt(8)")  
//get the list before 8th position 
//i.e greter than 8

Read the next part here.

Advertisement

1 comment

Leave a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: