Solved

overwriting of <div>

Posted on 2011-09-18
21
237 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Basic JavaScript Question 3 39
JavaScript: Issue with onClick 5 36
Alignment is not working correctly. 8 33
help squeezing some space out in this site 9 20
This article discusses how to create an extensible mechanism for linked drop downs.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

863 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

23 Experts available now in Live!

Get 1:1 Help Now