Skip to content

Instantly share code, notes, and snippets.

@witoong623
Last active June 12, 2017 04:27
Show Gist options
  • Save witoong623/51106a496726c89cf3cd8b3a446a22e4 to your computer and use it in GitHub Desktop.
Save witoong623/51106a496726c89cf3cd8b3a446a22e4 to your computer and use it in GitHub Desktop.
A demonstration of setInterval, used for changing title
<html>
<head>
<title></title>
</head>
<body>
<script
src="https://code.jquery.com/jquery-3.2.1.min.js"
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous"></script>
<script>
let collectionText = ['I dont want to learn', 'anymore']
let index = 0
setInterval(function() {
if (index === 0) {
$('title').text(collectionText[index])
index = 1
} else {
$('title').text(collectionText[index])
index = 0
}
}, 2000)
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment