Jump to content

question of slide function


justAnoob

Recommended Posts

I have a js function that slides open a div when an image is clicked. When the page loads, the div is already open. How would I have the div closed when the page loads.  Somehow run the script on page load so the div is closed ?  Tried it, cannot get it to work. Any ideas?

Link to comment
Share on other sites

Assume the function that you have is called openDiv(),

then if You got jquery then you use document.ready function,

 

$(document).ready(function(){
  openDiv();
}); 

But if you didn't use jquery, try

 

<body onload="openDiv()">

<div id="close" onclick="openDiv()" style="display:none"></div>

Link to comment
Share on other sites

Lets say, I have a picture of an 'x'

when the 'x' is clicked on, a div is displayed(sliding open)

that works, but I would like the div closed on page load, so when the user clicks on the x, the div slides open

<div style="position:relative; width:240px; height:200px; margin-bottom:5px;">
          <div style="position:absolute; width:18px; height:32px; right:162px; top:-7px; background-color:#9AA4AD; text-align:center; cursor:pointer; padding:0px;" onclick="Slide();" >
           <table width="100%" height="32px" cellspacing="0" cellpadding="0">
            <tr>
             <td align="center" valign="middle" style="text-size:9pt;">
               <img src="images/K_little.png" width="29" border="0" height="32" /></td>
            </tr>
           </table>
          </div>
         <div id="exampleSlider" style="position:absolute; top:36px; left:0px; width:240px; height:200px; background-color:#9AA4AD; overflow:hidden;">
          <table width="100%" height="100%">
           <tr>
            <td valign="top" style="padding:3px;">
             <textarea name="message_2_user" cols="23" rows="8" style="overflow:auto; border:thin #000"> </textarea>
             <br />
             <br />
		 <?php
		if( (!isset($_SESSION['auth'])) || (!isset($_SESSION['id'])) )
            {
		   echo 'Please log in to send messages.';
		}
		else
		{
		   echo '<input type="submit" name="submit" id="submit" value="Send Message" />';
		}
		?>            
            </td>
           </tr>
          </table>   
         </div>
         Click the            to send a message. </div>

               

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.