jQuery होवर () विधि
उदाहरण
जब माउस पॉइंटर उस पर होवर करता है तो <p> तत्व की पृष्ठभूमि का रंग बदलें:
$("p").hover(function(){
$(this).css("background-color", "yellow");
}, function(){
$(this).css("background-color", "pink");
});
परिभाषा और उपयोग
जब माउस पॉइंटर चयनित तत्वों पर होवर करता है तो होवर () विधि दो कार्यों को चलाने के लिए निर्दिष्ट करती है।
यह विधि माउसेंटर और माउसलीव ईवेंट दोनों को ट्रिगर करती है।
नोट: यदि केवल एक फ़ंक्शन निर्दिष्ट किया गया है, तो यह माउसेंटर और माउसलीव ईवेंट दोनों के लिए चलाया जाएगा।
वाक्य - विन्यास
$(selector).hover(inFunction,outFunction)
Parameter | Description |
---|---|
inFunction | Required. Specifies the function to run when the mouseenter event occurs |
outFunction | Optional. Specifies the function to run when the mouseleave event occurs |