by lynne.codes
<img class="preview-img" src="images/Avatar-EyesOpen.svg">
.avatar:hover { content: url("images/Avatar- Happy.svg"); }
Why did the scarecrow win an award?
<id="joke">Why did the scarecrow win an award?</p> <button type="button" onclick='document. getElementById("joke").innerHTML = "Because he was outstanding in his field"'>Why? </button>
//see HTML
<img class="preview-img" src="images/Avatar-EyesOpen 2.svg"> <button onclick="eyesOpen()">Eyes Open </button> <button onclick="eyesClosed()">Eyes Closed </button>
function eyesOpen() { document.getElementById("avatar-img2") .src="images/Avatar-EyesOpen 2.svg"; } function eyesClosed() { document.getElementById("avatar-img2") .src="images/Avatar-Happy 2.svg"; }
<img src="Avatar-EyesOpen.png" onmouseover="makeImageLaugh(this)" onmouseout="makeImageSmile(this)">
function makeImageLaugh(image) { image.src = "Avatar-Happy.png"; } function makeImageSmile(image) { image.src = "Avatar-EyesOpen.png"; }
<button onclick="alertMe()"> Click Me</button>
function alertMe() { alert("Why Hello!"); }
Days Until 2021:
<p>Days Until 2021: </p> <p id="countdownDays"></p>
var countDownDate = new Date("Jan 01, 2021").getTime(); var x = setInterval( function() { var now = new Date().getTime(); var distance = countDownDate - now; var days = Math.floor(distance / (1000 * 60 * 60 * 24)); document.getElementById ("countdownDays").innerHTML = days + " " + "days"; }, );
<form class="myvisitorform" action="" method="get">What is your name? <input type="text" name="inputbox" value=""> <input type="button" name="button" value="Submit" onClick="visitor(this.form)"> </form>
function visitor(form) { var visitorName = form.inputbox.value; alert ("Your name is " + visitorName); }
<button onclick="window.print()"> Print This Page </button>
//see HTML
Random Number (0-1):
<p>Random Number (0-1):</p> <p id="randomnum"></p>
document.getElementById("randomnum") .innerHTML = Math.random();
Convert 300 mL to oz:
<p>Convert 300 mL to oz: </p> <p id="solve"></p>
function toOunces(mL) { return (mL/30); } document.getElementById("solve").innerHTML = toOunces(300);