Can you please take a look at following link and let me know why the toggle() is not working in the code?
http://jsfiddle.net/GISMan/ZNkKZ/1/
here is the code as well,
function fluctuate(bar) {
var hgt = Math.random() * 10;
hgt += 1;
var t = hgt * 30;
bar.animate({
height: hgt
}, t, function() {
fluctuate($(this));
});
}
$(".bar").each(function(i) {
fluctuate($(this));
});
$("button").toggle(function(){
$(".bar").stop();},
function(){
$(".bar").fluctuate();}
);
Thanks for your comments
DEMO — Fixed.
Change:
to: