brahimm brahimm - 1 year ago 73
Javascript Question

events load and ready not firing

This is my code:

$(document).on('ready load click',function(){

I included the jquery script above.
The problem is the click event is firing but the load or ready event is not.
I don't see any error in my console.
What could be the problem?

Answer Source

Which Version of jQuery are you using

According to jQuery docs

$(document).on( "ready", handler ), deprecated as of jQuery 1.8 and removed in jQuery 3.0. Note that if the DOM becomes ready before this event is attached, the handler will not be executed.

$( window ).load(function() {

     alert("in click event");
<script src=""></script>

  1. Window onload: :Is fired when all the content including images has been loaded

  2. document.ready : Is fired after html document is loaded

So i guess you cannot combine all three events ready,load and click the way you have tried

Hope it helps

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download