I\'m looking for a way to do the following.
I add a I couldn't find exactly what I was looking for so wrote something as basic as I could make it. The highlighted class could just be a background color. I use different predefined colors like so: and use them like this easy :) If you are not already using the Jquery UI library and you want to mimic the effect what you can do is very simple you can also play around with the numbers to get a faster or slower one to fit your design better. This can also be a global jquery function so you can use the same effect across the site. Also note that if you put this code in a for loop you can have 1 milion pulses so therefore you are not restricted to the default 6 or how much the default is. EDIT:
Adding this as a global jQuery function Blink any element easily from your site using the following Check it out - This is a custom blink effect I created, which uses HTML - JS - As simple as it gets. http://jsfiddle.net/Ajey/25Wfn/ Try with jquery.blink.js plugin: https://github.com/webarthur/jquery-blink #enjoy!
var blinking = false; // global scope
function start_blinking() {
blinking = true;
blink();
}
function stop_blinking() {
blinking = false;
}
function blink(x=0) {
$("#element").removeClass("highlighted"); // default to not highlighted to account for the extra iteration after stopping
if (blinking) {
if (x%2 == 0) $("#element").addClass("highlighted"); // highlight on even numbers of x
setTimeout(function(){blink(++x)},500); // increment x and recurse
}
}
theme = {
whateverFlashColor: '#ffffaa',
whateverElseFlashColor: '#bbffaa',
whateverElseThenFlashColor: '#ffffff',
};
$('#element').effect("highlight", {color:theme.whateverFlashColor}, 1000);
$('#blinkElement').fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100);
$.fn.Blink = function (interval = 100, iterate = 1) {
for (i = 1; i <= iterate; i++)
$(this).fadeOut(interval).fadeIn(interval);
}
$('#myElement').Blink(); // Will Blink once
$('#myElement').Blink(500); // Will Blink once, but slowly
$('#myElement').Blink(100, 50); // Will Blink 50 times once
<input type="button" id="btnclick" value="click" />
var intervalA;
var intervalB;
$(document).ready(function () {
$('#btnclick').click(function () {
blinkFont();
setTimeout(function () {
clearInterval(intervalA);
clearInterval(intervalB);
}, 5000);
});
});
function blinkFont() {
document.getElementById("blink").style.color = "red"
document.getElementById("blink").style.background = "black"
intervalA = setTimeout("blinkFont()", 500);
}
function setblinkFont() {
document.getElementById("blink").style.color = "black"
document.getElementById("blink").style.background = "red"
intervalB = setTimeout("blinkFont()", 500);
}
</script>
<div id="blink" class="live-chat">
<span>This is blinking text and background</span>
</div>
setInterval
and fadeTo
<div id="box">Box</div>
setInterval(function(){blink()}, 1000);
function blink() {
$("#box").fadeTo(100, 0.1).fadeTo(200, 1.0);
}
<script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script src="/path/to/jquery.blink.js"></script>
<script>
jQuery('span').blink({color:'white'}, {color:'black'}, 50);
</script>