So I am writing a code that displays an alert box whenever the mouse hovers over a piece of text in HTML. The problem that I have is it is not working and I am not sure why. I tried finding help online but none of them worked. I need something that doesn’t use JQuery for this assignment. What I have tried is to use function when activated with the mouse over event handler but that also didn’t work.
This is my code:
function mouseOver(){
showAlert();
}
function showAlert(){
alert("Alert!");
}
This is another method that I have tried:
function mouseOver(){
document.getElementById("text").alert("Alert!");
}
>Solution :
Try this
function mouseOver(){
alert("Alert!");
}