Running jQuery inside $(window).load() function but not inside $(document).ready function -


i have existing function icons in web page using jquery ui position plugin:

<script type='text/javascript'> jquery( document ).ready( function( $ ) { var element_selector='.test'; if ( $(element_selector).length !== 0) {  //jquery ui position code here  }   }); </script> 

this function found near footer section of html although in places outputs on head section. suggested me load jquery inside $(window).load() function. reason $(document).ready event fired when dom loaded, it’s fired when document structure ready, before images loaded.

$(window).load() event fired after whole content loaded. .position() method might not calculate correct position when it’s fired (before images loaded).

if true, how revise above load in $(window).load(). thanks.

update: have changed from:

jquery( document ).ready( function( $ ) { 

to this:

jquery(window).load(function($) { 

and error in console:

uncaught typeerror: object not function  

it fails on line:

$(divname515e62e8355b0).children().wrapall('<div class="mydoc cf">'); 

where divname515e62e8355b0 selector define here:

var divname515e62e8355b0 = '#test_selector'; 

jquery(window).load(function($) {     var element_selector='.test';     if ( $(element_selector).length !== 0) {         // stuff     } }); 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -