Uncaught TypeError: object is not a function when changing jQuery loading method -


this related here: running jquery inside $(window).load() function not inside $(document).ready function

before using:

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

to load jquery ui position code decided try load using:

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

now error:

uncaught typeerror: object not function 

this code before change:

<script type='text/javascript'> jquery( document ).ready( function( $ ) { var element_selector='.test'; if ( $(element_selector).length !== 0) {  var divname515e62e8355b0 = '#test_selector'; $(divname515e62e8355b0).children().wrapall('<div class="mydoc cf">');  //jquery ui position code here  }   }); </script> 

this code after change:

<script type='text/javascript'> jquery(window).load(function($) { var element_selector='.test'; if ( $(element_selector).length !== 0) {  var divname515e62e8355b0 = '#test_selector'; $(divname515e62e8355b0).children().wrapall('<div class="mydoc cf">');  //jquery ui position code here  }   }); </script> 

but error:

uncaught typeerror: object not function 

this problem line:

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

i've checked commas, semicolons , there seems fine. problem?

thanks tips.

that's because in second code, $ event object, .load() doesn't behave .ready() method, if want avoid conflict use self-invoking function:

(function($) {     $(window).load(function(event) {         // ...     }); })(jquery); 

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 -