jQuery - How to remove a DOM element BEFORE complete page load
- by webfac
Now this may seem like a silly question, but I need to know how to remove a DOM element BEFORE it is displayed to the user. In short, I am using a div that has a background image alerting the user to enable javascript before proceeding. If the user has javascript enabled I am using jQuery to remove the DOM element, in this case $(".check-js") which is the div housing the image.
Using the conventional methods to unload DOM objects as follows does not work because it waits for the page load to complete, then removes the element, causing the image to flicker on and off each time the page loads:
$(function(){
$(".check-js").css( {display:"none"} )
})
I simply want to remove the div if the user has js enabled, and he must never see this div.
Any suggestions and I will be grateful, thanks.