javascript - jQuery conflict when removing div after page load -
i'm trying remove div page (preferably prevent loading @ all) i'm settling on removing after page loads.
when try following lines of code in jsfiddle, #content
div gets removed, expected.
<script type='text/javascript'>//<![cdata[ $(window).load(function(){ $('#content').remove(); });//]]> </script>
however, have tried implementing on an actual website, in case, #content
div isn't removed.
any suggestions might wrong?
if you're sharing jquery library uses dollar operation need guard against this, using anonymous wrapper:
(function($) { $(window).on('load', function(){ $('#content').remove(); }); }(jquery));
note instead of .load() i'm using .on('load', fn).
instead of on page load bind code on dom ready; jquery passes first argument inner function:
jquery(function($) { $('#content').remove(); });
Comments
Post a Comment