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
https://forums.phpfreaks.com/topic/265802-show-div-on-top/
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
https://forums.phpfreaks.com/topic/265802-show-div-on-top/#findComment-1362536
Share on other sites

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.