Solved

overwriting of <div>

Posted on 2011-09-18
21
236 Views
Last Modified: 2012-05-12
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
0
Comment
Question by:savsoft
  • 11
  • 10
21 Comments
 
LVL 40

Accepted Solution

by:
gurvinder372 earned 500 total points
ID: 36558290
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
 

Author Comment

by:savsoft
ID: 36558318
can we use z-index for <td> tag also.....???? because one div is overlaying another <td>
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 36558325
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
 

Author Comment

by:savsoft
ID: 36558371
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
 
LVL 40

Expert Comment

by:gurvinder372
ID: 36558385
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
 

Author Comment

by:savsoft
ID: 36558395
and if index 3 div is hidden.....will the div with index 2 will be enabled automatically
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 36558399
Yes
0
 

Author Comment

by:savsoft
ID: 36558404
shukriya.....:P:P
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 36558418
Glad to help. Please respond to your other open questions as well
0
 

Author Comment

by:savsoft
ID: 36558684
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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:savsoft
ID: 36558697
thanks in advance
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 36558863
please explain the parameters of this method
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 36558882
which one is div with index 1 and which one is div with index 2
0
 

Author Comment

by:savsoft
ID: 36558905
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
 
LVL 40

Assisted Solution

by:gurvinder372
gurvinder372 earned 500 total points
ID: 36558914
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
 

Author Comment

by:savsoft
ID: 36558981
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
 
LVL 40

Expert Comment

by:gurvinder372
ID: 36558984
is it possible for you to share live internet link
0
 

Author Comment

by:savsoft
ID: 36559019
www.labbo22.com

username is : contacts@savsoft.co.in
password is sasasa...come there i ll tell you what i want
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 36559027
how should i login? i don't see the link to login
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 36559029
i am able to login, but it says unable to post
0
 

Author Comment

by:savsoft
ID: 36559035
ya plz login there again.....actually i have unblocked you... because we were testing so come back..thr?
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now