Jump to content

JQuery and CSS not performing as expected


webguync

Recommended Posts

Hi,

 

I have some code which is supposed to make a div appear with text inside after a set timed amount has passed. I am trying it out and it does seem to be working (appearing). Here is what I am doing.

 

JavaScript

 

<script language="javascript" type="text/javascript" src="js/Validation.js"></script>
<script type="text/javascript">

$setTimeout(function() {
      $('#object').slideDown().fadeOut(50).fadeIn(50).fadeOut(50).fadeIn(50).fadeOut(50).fadeIn(50);
}, 2000);

   
   //close the message box when the cross image is clicked 
   $("#close_message").click(function()
{
   $("#object").fadeOut("slow");
});
});
</script>

 

and the html looks like this:

 

<div id="object" class="message"> 
  <img id="close_message" style="float:right;cursor:pointer"  src="images/12-em-cross.png" />
    
  <p><strong>Your time is up! Please submit your answers!</strong></p>
</div>

 

CSS...

 

.message{
       border:5px solid #CCCCCC;
position:absolute;
width:150px;
border:1px solid #c93;
background:#ffc;
padding:5px;
right:0px;
top : -140px;
}


 

any ideas on what I am doing wrong?

 

No need for the $ at the start of setTimeout.

 

setTimeout(function() {
      $('#object').slideDown().fadeOut(50).fadeIn(50).fadeOut(50).fadeIn(50).fadeOut(50).fadeIn(50);
}, 2000);

 

You could also try placing an alert inside the setTimeout to see if it's actually working. And why so many effects?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.