Reputation: 289
I am trying to create a document ready function without the need of a click, in other words I want the script to be executing all the time on page load.
What I am trying to do is if a div, lets say DIV 1 is not visible on the page then I want my second div, DIV 2 to fade in.
This seems simple but I am having problems getting this to work, please can someone show me where I am going wrong.
<script type="text/javascript">
$(document).ready(
function(){
$("HTML BODY").onLoad(function () {
if($('.noti_box').is(':hidden')){
$(".advert").fadeIn("slow");
});
}});
</script>
Upvotes: 1
Views: 35
Reputation: 337560
Your syntax is a little off. There is no onLoad
event in jQuery. You can just put the code to run within the document.ready
handler and it will execute as soon as the DOM has been loaded. Try this:
$(document).ready(function(){
if ($('.noti_box').is(':hidden')) {
$(".advert").fadeIn("slow");
}
});
Upvotes: 2