Tuesday, July 11, 2017

Describe hover() & focus().

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

$("#p1").hover(function(){
    alert("You entered p1!");
},
function(){
    alert("Bye! You now leave p1!");
});


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", "#cccccc");
});