Created
May 7, 2018 11:20
-
-
Save jamalnasir/c322754ee4b21114d27e40684616469f to your computer and use it in GitHub Desktop.
Flash a DIV element using jQuery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script> | |
</head> | |
<body> | |
<div id="divtoBlink"> | |
<h1>This is the element to blink</h1> | |
</div> | |
<style> | |
.backgroundRed{ | |
background: lightblue; | |
} | |
#divtoBlink{ | |
color: #000; | |
-webkit-transition: background 1.0s ease-in-out; | |
-ms-transition: background 1.0s ease-in-out; | |
transition: background 1.0s ease-in-out; | |
} | |
</style> | |
<script> | |
var $div2blink = $("#divtoBlink"); // Save reference, only look this item up once, then save | |
var backgroundInterval = setInterval(function(){ | |
$div2blink.toggleClass("backgroundRed"); | |
},1500) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment