What is the syntax to get this bit of jQuery to call when say, h2.myClass is hovered?
$(document).ready(function(){
setTimeout(function(){
$("div.clickme, div.clickMeTimes").fadeOut("slow", function () {
$("div.clickme, div.clickMeTimes").remove();
});
}, 2500);
});
Thanks to all the answers, alot of them were very good but @SKS went the extra mile with my extra requirements. The below fades in my div in and out on mouse hover instead of the initial on page load.
$(document).ready(function(){
$('h2.myClass').hover (function() {
$("div.clickme, div.clickMeTimes").stop(true).fadeOut("slow");
}, function () {
$("div.clickme, div.clickMeTimes").stop(true).fadeIn("slow");
});
});
Since you want something to be executed only on mouse enter. You can just use
mouseenterfunction.I think below is what you want,
Also modified
$("div.clickme, div.clickMeTimes").remove();inside the callback to$(this).remove()which will remove the corresponding element instead of trying to remove both element.Edit: Try below, If you it to fadeIn and fadeOut.