Change all but one element

Discussion in 'JavaScript' started by decepti0n, Jun 9, 2007.

  1. #1
    I'm trying to make a 'popup' sort of, it's just a css div which starts off hidden, then becomes visible when a link is clicked (like the IPB buddy popup)

    As well as this, im trying to make the entire document see-through-ish by setting it's opacity to 0.4.

    It all works, everything becomes semi-transparent, but so does the div i need to be fully visible. If i take away the part that makes it transparent, the div is also fully visible (how I want it)

    function quickmail() {
    	var html = document.getElementsByTagName("*");
    	for(i=0;i<html.length;i++) {
    		if (html.item(i).getAttribute("id") != "hide_quickmail") {	
    			html.item(i).setAttribute("style","opacity:0.4;");
    		} else {
    			alert('bah');
    		}
    	}
    	// Change to createelement etc later
    	document.getElementById("hide_quickmail").style.display = "block";
    }
    Code (markup):
    The div is the one with an id of 'hide_quickmail'. As well, it gives me the alert, so i know that it's doing the else at the right place, it's just afterwards, it's also semi-transparent.

    I dont know if its because the hide_quickmail div is inside another one which becomes transparent, and it carries down, if it is, is there any way to stop it? Sorry I dont really have a demo available, its part of a larger system and it'd take a while to seperate what's needed.

    Thanks for any help
     
    decepti0n, Jun 9, 2007 IP
  2. decepti0n

    decepti0n Peon

    Messages:
    519
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Well, it works well enough with just selecting all divs, I'll go with that for now, but if anyone has any ideas as well I'm still up for some help.

    Thanks
     
    decepti0n, Jun 9, 2007 IP
  3. CygnetGames

    CygnetGames Peon

    Messages:
    43
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You could make everything semitransparent, then make your popup div opaque again.
    You can get a reference to your popup div by giving it an "id" and using document.getElementById()

    This page might be helpful:
    http://www.w3schools.com/htmldom/dom_nodes_access.asp
     
    CygnetGames, Jun 10, 2007 IP