I'm having a little trouble and want to ask why my Javascript code is not working here. This is my HTML / CSS / Java Script code.
I want to create a form with a small tooltip on user ID when user hover their mouse in input area, it will appear the "Student ID" box.
HTML
<p>Account Information</p>
<p>
<label for="sid" >User ID</label>
<input type="text" name="sid" id="sid" />
<span id="sidTip" class="tooltip">Student ID</span>
</p>
CSS
.tooltip {
display : none;
position : relative;
background-color : lightblue;
border-radius : 5px;
text-align : center;
padding : 5px;
left : 1em;
}
.tooltip:after {
position : absolute;
top : 10px;
border-style : solid;
height : 0;
width : 0;
}
Javascript
function showTip() {
var sidTip = document.getElementById("sidTip");
sidTip.style.display = "inline";
}
function hideTip() {
var sidTip = document.getElementById("sidTip");
sidTip.style.display = "none";
}
function init() {
var sid = document.getElementById("sid");
sid.onmouseover=showTip();
sid.onmouseout=hideTip();
}
window.onload=init();