Hi, I’ve been working on this little script and it almost works except on the page loads it shows immediately and I would like to get to start on page load between something like 5-30 seconds.
How can I do this as I’ve tried about everything I can find on Google?
Here’s my code so far:
function refreshData(){
var min = 2,
max = 40;
var rand = Math.floor(Math.random() * (max - min + 1) + min);
var audio = new Audio('bobble-pop.mp3');
var myArray = ['Trees','Dogs','Cats'];
setTimeout(refreshData, rand * 1000);
$(document).ready(function() {
var randomTitle = myArray[Math.floor(Math.random() * myArray.length)];
$.meow({
message: $('#onready'),
icon: 'cat.gif',
title: randomTitle,
});
audio.play();
});
}
refreshData();
You could retrieve the text using innerHTML, break it apart within JavaScript using split or substring, and then replace the existing text with a span and class.
Can we get some details on how that title is affected by scripting, and how it makes it to the page?
// Add title if it's defined
if (typeof this.title === 'string') {
this.manifest.find('.inner').prepend(
$(window.document.createElement('h1')).text(this.title)
);
}
How does the onready part relate to the .inner part in the code? And how does that title part with the random title and some stuff here, relate to what you’ve given here?