I am new to JavaScript and jQuery, so I think I have some kind of misunderstanding of how this stuff should work. What I am doing is loading some html via .load (), then I call the previously defined function as a callback function. This function does not do the same as when I define it directly in place:
$(document).ready(function(){ $('#playerslot').html( '' ).load('player/',function(){ $('#new_element').replaceWith('Hello World!') }); });
The above code works, but it doesn't:
function hello(){ $('#new_element').replaceWith('Hello World!') }); $(document).ready(function(){ $('#playerslot').html( '' ).load('player/',hello()); });
Why not?
marue source share