here is my codes:
$('.classname').on('click',function myfunc() {
alert ('working ..!');
});
the above code works correctly and when I click on the div .classname
, it gives me a message: working ..!
Now I want to use of that function (myfunc
) for onload event. here is my try:
window.onload = myfunc;
window.onload = myfunc();
document.onload = myfunc();
<body onload = "myfunc()">
object.onload=myfunc(){alert ('working ..!');}
but none of them does not works. Why ?! Why, when I refresh the page don't see any message ? How can I fix it ?