Last active
June 12, 2017 04:27
-
-
Save witoong623/51106a496726c89cf3cd8b3a446a22e4 to your computer and use it in GitHub Desktop.
A demonstration of setInterval, used for changing title
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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