Jump to content

show div on top


cmb

Recommended Posts

right now this is my code for clicking a button and it shows a div, click it again and it disappears. what i want to do is i just show that div on top of the rest how would i modify this to do that

function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.display == 'none')
e.style.display = 'block';
else
e.style.display = 'none';
}

Link to comment
Share on other sites

use something like this . its the show function in jquery in its preety cool and simple .

hope it helps .

Avi. (you can create html page with this code just to check how its work for you , this example been taken from http://api.jquery.com/show/    )

 

<!DOCTYPE html>

<html>

<head>

  <style>

  div { background:#def3ca; margin:3px; width:80px;

  display:none; float:left; text-align:center; }

  </style>

  <script src="http://code.jquery.com/jquery-latest.js"></script>

</head>

<body>

 

  <button id="showr">Show</button>

  <button id="hidr">Hide</button>

  <div>Hello 3,</div>

 

  <div>how</div>

  <div>are</div>

  <div>you?</div>

<script>

$("#showr").click(function () {

  $("div").first().show("fast", function showNext() {

    $(this).next("div").show("fast", showNext);

  });

});

 

$("#hidr").click(function () {

  $("div").hide(1000);

});

</script>

 

</body>

</html>

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.