Using hover, focus and blur in JQuery

Amatya
Posted by Amatya under jQuery category on | Points: 40 | Views : 4627
hover()

The hover() method takes two functions and is a combination of the mouseenter() and mouseleave() methods.
The first function is executed when the mouse enters the HTML element, and the second function is executed when the mouse leaves the HTML element:

Example
$("#DNF").hover(function(){
alert("DNF Here");
},
function(){
alert("Bye DNF");
});


focus()

The focus() method attaches an event handler function to an HTML form field.
The function is executed when the form field gets focus:

Example
$("input").focus(function(){
$(this).css("background-color", "Red");
});



blur()
The blur() method attaches an event handler function to an HTML form field.
The function is executed when the form field loses focus:

Example
$("input").blur(function(){
$(this).css("background-color", "Blue");
});


Thanks
Amatya

Comments or Responses

Login to post response