JSFiddle - React, Tailwind, and code Playground
by Łukasz Cyran
HTML
<a href="#" onclick="return getRandomTip();">Get a tip!</a>
<div id="output">Check tips.</div>
JavaScript
var tips = [
"First tip",
"Second tip",
"Third tip",
"Learn programming",
"Baby don't click me, don't click me, no more",
"Wasted tip"
];
function getRandomTip() {
var randomTipIndex = Math.floor((Math.random() * tips.length));
var randomTip = tips[randomTipIndex];
$.ajax({
url:'/echo/js/?js=' + randomTip,
complete: function (response) {
$('#output').html(response.responseText);
}
});
return false;
}