overwriting of <div>

i have two <div> tags on same position . how to assign z-index to them so that when i click on one div tag so that one become enable and become disabled......


Thanx in advance
savsoftAsked:
Who is Participating?
 
Gurvinder Pal SinghConnect With a Mentor Commented:
only way to disable a div, as far as i know, is by overlaying another div on top of it with higher z-index

<div id="divToBeOverlayed"></div>

<div id="divThatOverlays"></div>

#divToBeOverlayed
{
  position:absolute;
  top:100px;
  left:100px;
  height:100px;
  width:100px;
  z-index:1;
}

#divThatOverlays
{
  position:absolute;
  top:100px;
  left:100px;
  height:100px;
  width:100px;
  z-index:3;
}

since the z-index of the divThatOverlays is higher, it will come on top and divToBeOverlayed will look like disabled
0
 
savsoftAuthor Commented:
can we use z-index for <td> tag also.....???? because one div is overlaying another <td>
0
 
Gurvinder Pal SinghCommented:
Yes, it can be used for any element as long as you have positioned that element.
http://www.w3schools.com/cssref/pr_pos_z-index.asp

you need to give position:relative for that td
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
savsoftAuthor Commented:
One more thing gurvinder....is there any way that if one div is there of index 2 and one of index 3....when idiv with index 2 is hidden then index of div 3 get enabled automatically
0
 
Gurvinder Pal SinghCommented:
i guess, even if the div with z-index 2 is not hidden, div with z-index 3 will always be enabled regardless, since it will be on top of div with index 2.
Higher index takes more priority and it overlays whatever is beneath with lower z-index
0
 
savsoftAuthor Commented:
and if index 3 div is hidden.....will the div with index 2 will be enabled automatically
0
 
Gurvinder Pal SinghCommented:
Yes
0
 
savsoftAuthor Commented:
shukriya.....:P:P
0
 
Gurvinder Pal SinghCommented:
Glad to help. Please respond to your other open questions as well
0
 
savsoftAuthor Commented:
i want to hide second div whose z-index:2 and enable to first div whose z-index:1  by calling function

function hidestuff(id,toph,main)
{
document.getElementById(main).style.border="none";
document.getElementById(id).style.display="none";
}

it hide second div but doesn't enable first div


0
 
savsoftAuthor Commented:
thanks in advance
0
 
Gurvinder Pal SinghCommented:
please explain the parameters of this method
0
 
Gurvinder Pal SinghCommented:
which one is div with index 1 and which one is div with index 2
0
 
savsoftAuthor Commented:
i have two div

one with index 1 and one with index 2........ when i click on one link then i want ke zindex get replaced that is the procedure i want...... so plz explain me with short example
0
 
Gurvinder Pal SinghConnect With a Mentor Commented:
function replaceZIndex(divId1, divId2)
{
   var divId1ZIndex = document.getElementById(divId1).style.zIndex;
 
   document.getElementById(divId1).style.zIndex = document.getElementById(divId2).style.zIndex;

   document.getElementById(divId2).style.zIndex = divId1ZIndex ;
}

0
 
savsoftAuthor Commented:
i am not able to solve problem its just like facebook chat ....when chat window get opens then area behind that window become absolute
0
 
Gurvinder Pal SinghCommented:
is it possible for you to share live internet link
0
 
savsoftAuthor Commented:
www.labbo22.com

username is : contacts@savsoft.co.in
password is sasasa...come there i ll tell you what i want
0
 
Gurvinder Pal SinghCommented:
how should i login? i don't see the link to login
0
 
Gurvinder Pal SinghCommented:
i am able to login, but it says unable to post
0
 
savsoftAuthor Commented:
ya plz login there again.....actually i have unblocked you... because we were testing so come back..thr?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.