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?

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.