Onload event in <form> tag

I want a JavaScript function to execute on page load.

I added an attribute onload

to the tag <form>

but it alert

fails.

What am I doing wrong?

<form name=myfm method=post action=quiz.php onload = alert('hello')>

      

+3


source to share


2 answers


try adding onload

to tagbody



<body onload="alert('Hello World')">

      

+3


source


//  javaScript
window.onload = function{
   alert("loaded");
}


//  jquery
 $(document).ready(function() {
    $("#div-id").click(function(){ 
    alert("the page is loaded");
    }); 
});

      



0


source







All Articles