Skip to main content

Posts

Showing posts with the label document.ready() vs body.onload() function in jQuery

jQuery click vs on events

The . click () events are only attach to fully loaded elements and can't use for dynamic added elements and utilize more memory and create event handler for each child. The .click() requires to event handler for all element which are attached. It is produce the overhead at time for DOM manipulations. The   .on( )  events are used for both dynamic added elements and its consume less memory then .click() events. It allows creating the event handler which elements are added dynamically ways. The .on() will work for current and future elements and it a replacement of the bind(), live() and delegate() methods. The Example over click() vs. on() in details as given below, For .click() events :- The HTML code, < ul   id ="click">      < li > List items </ li > </ ul > The JavaScript code, $( '#click li' ).click( function  () {     $( this ).parent().append($( '<li>New List i...

What is $(document).ready() function? Why we use it?

The $(document). ready () function is  use to execute the code when the DOM is fully loaded.  We can say that $(document).ready() is an event which is fire when DOM is fully loaded or ready to use. Document Ready function:- We can call more than one document.ready() function in single page. The  document.ready()  function is called when  DOM  is not fully loaded that means rest of images, css or other 3rd party reference on page. It will not wait for the images, css or other 3rd party to get loaded. The ready and load events: 1.       $(document).on('ready', handler) 2.       $(document).on('load', handler) I Hope it is helpful to you! Thank you!

difference between document ready and body onload in jQuery

The main differences are the  $(document).ready()   event called when your   HTML   document is loaded and DOM is ready and it's don't wait for your content and images etc. fully loaded but    window.onload() (<body onload="func();">) event is  wait for your content and images etc. fully loaded. The $(document).ready() function is called only one time when your page is loading not for partial page rendering in that case you need to use pageLoad() function. Document Ready function:- We can call more than one document.ready() function in single page. The  document.ready()  function is called when  DOM  is not fully loaded that means rest of images, css or other 3rd party reference on page. It will not wait for the images, css or other 3rd party to get loaded. Body Onload function:- The body.onload() function, we can have only one body.onload() function. The body.onload() function i...

jQuery Interview Questions and Answers

What Is jQuery? jQuery is a fast and rich JavaScript library that work between the HTML and JavaScript and used to handle the various events, Ajax call and easy to communicate with APIs and it work with most of brewers. What is $(document).read () function? Why we use it? Difference between document.ready() and body onload in jquery What is jQuery.noConflict? Document ready vs. window load JQuery bind() vs. live() vs. delegate() vs. on() methods JQuery click vs. on events What is jQuery Selectors? The selectors are used to select the HTML elements from your HTML page. The selector can be css selector or custom selector. The selectors are start with $ and end with (). There are three types of selectors as given below. 1.       Selector can be used by tag name. i.e. $(div) 2.       Selector can be used by Ids. i.e. $("#ids") 3.       Selector can be used by css class. i.e. ...