JQuery a unique thing part- III

Hello friends,

today i am with new topic of jQuery which is events.  after this we will work on   Jquery + AJAX  & Jquery + Asp.net 3.5  so bear with me on events. here we goes.

Ans: Jquery event system is normalize the event object.Then event object is guranteed to be passed in event handler.

Here is more description

1) event.type :- Determine the nature of event.

Ex:- $(a).click(function(event) { alert(event.type);}); it will return “click”

2) event.target:- Give the refrence of DOM element which raised the event.

EX:- $(a).click(function(event){alert(event.target.href);});

Return the url which is assign to a for href property.

3)event.pageX/pageY: – return the mouse position (cordinate) relative to the document.

Ex:- $(a).click(function (event){ alert(event.PageX); alert(event.PageY); });

4) event.preventDefault() :-

it will stop the default exceution action.

EX:- $(a).click(function(event) { event.preventDefault(); alert(‘test’);}); stop the a href ( transfer to another page)

The above are the basic for event object.

5) ready :- On of the most and basic event for Jquery is ready().

It bind the function to be executed when ever the document is ready for traverse and mainupulate.

Its base of jquery it improve web performance as well.

You many have as many as ready event in your web form. It will execute in the order as you define the events. It’s a solid replacment of window.load()

6) Bind() :- Suppose you have more than one paragraph and you want same event on each paragraph then instead of writing each paragraph event.you can bind paragraph with particular event.

Ex:- $(“p”).bind(“onmouseover”, function (){ $(this).css(“background- color”,”red”);});

7)One() :- suppose we want a event only once on the document then we can bind the event by one.

Then it will run only once on the particular event.

Ex:- suppose we want click event only once on all the div then

$(“div”).one(“click”,function() { ($(this).css(“background-color”, “blue”); });
8) unbind() :- it will just do upposit the bind event.it unbind all the event for match element.

9) blur() :-

trigger blur event on each matched element. Or in other word we can say when focus is lost from the element then this event run.

Ex:- $(“txtName”).blur(function() { $(this).css(“border”,”2px”);});

9) change():- Change event fire when element’s value has been modified.

Ex:- $(“txtName”).change(function() { alert($(“txtName”).text();});

There are many more events which is as follow click(),

dblClick(),error(),focus(),KeyDown(),KeyPress(), keyUp(),Load(),mouseout(),mouseover(),mouseup(),mousedown(),resize(),Scroll(),




Leave a Reply

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 )

Google+ photo

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

Connecting to %s