I’m doing a ‘hover to peek’ script, and was hoping a guru could give me some guidance. Please read the code first, and then my ‘code-speak’
$(".peek").mouseenter(function() {
var $peek = $("#peek");
if ($peek.data("active")) { return; }
$peek.show().data("active", true);
setTimeout(function() {
$peek.hide().data("active", false);
}, 1000);
});
How can I say: “if $peek has been activated or if $peek has been hidden” do this ()
What my ultimate goal is here:
If hover on .peek, show #peek for 1 second, and then if you’ve seen #peek, disable the ability to hover on .peek so you can no longer see #peek.
In your code,
if ($peek.data("active"))retrieves eitherfalseorundefined, while you only want to run the rest of your code if it isundefined.