dynamically changing site title
-
Hi folks. I would like to make my site title dynamically change, using a set of random words. Has anyone done this or know a way using Lay? I imagine it needs some jquery?
Let's say the title is "MY WEBSITE". I want it to randomly change from time to time, to use other words. So it can become "MY LIFE", "GREAT WEBSITE", "MY WORLD", etc etc.
Any thoughts would be greatly appreciated it.
-
<script> /* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random */ function getRandomInt(min, max) { min = Math.ceil(min); max = Math.floor(max); return Math.floor(Math.random() * (max - min) + min); // The maximum is exclusive and the minimum is inclusive } var mywords = ['hello', 'hi', 'hallo', 'gutentag', 'salut']; setInterval(function(){ var i = getRandomInt(0, mywords.length); var word = mywords[i]; jQuery('.sitetitle-txt-inner span').text(word); }, 3000) </script>best to learn some programming! :)
-
<script> /* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random */ function getRandomInt(min, max) { min = Math.ceil(min); max = Math.floor(max); return Math.floor(Math.random() * (max - min) + min); // The maximum is exclusive and the minimum is inclusive } var mywords = ['hello', 'hi', 'hallo', 'gutentag', 'salut']; setInterval(function(){ var i = getRandomInt(0, mywords.length); var word = mywords[i]; jQuery('.sitetitle-txt-inner span').text(word); }, 3000) </script>best to learn some programming! :)
Thanks @arminunruh you're a star. That literally did exactly what I needed, it just doesn't work on mobile though I think it needs the mobile title class? I tried doing this below but no luck:
jQuery('.sitetitle-txt-inner span' , '.mobile-title text is-fixed').text(word);I've tried learning some programming over the years, but CSS is as far as it goes, and the good old "copy/paste/tweak until it works" approach. Appreciate your generous help.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login