...

View Full Version : creating divs not working



Phil Jackson
12-11-2009, 05:01 PM
Hi all, im trying to select certain elements from on screen and set the style of a div to over lap it.



$("body *").each(function(){
if($(this).attr("rel")!="nbta"){
alert("#div" + z + " style: " + "display:block; width:" + $(this).width() + "px; height:" + $(this).height() + "px; position:absolute; top:" + $(this).position().top + "px; left:" + $(this).position().left + "px; border: 1px solid red; z-index:" + $(this).parentNumber() + ";");

$("#div" + z).attr("style", "display:block; width:" + $(this).width() + "; height:" + $(this).height() + "; position:absolute; top:" + $(this).position().top + "; left:" + $(this).position().left + "; border: 1px solid red; z-index:" + $(this).parentNumber() + ";");
z++;
}
});



<p id="fooBar">dfgdsfdsfdsf1111</p>
<p id="fooBar2">dfgdsfdssdsdfdsf222</p>
<p id="fooBar3">dfgdsfdsfdsf333</p>
<p id="fooBar4">dfgdsfdsfdsf444</p>

<div id="div1" style="display:none" rel="nbta">&nbsp;</div>
<div id="div2" style="display:none" rel="nbta">&nbsp;</div>
<div id="div3" style="display:none" rel="nbta">&nbsp;</div>
<div id="div4" style="display:none" rel="nbta">&nbsp;</div>
seems easy enough and the results are showing corrent i just cant seem to get it to display!

Phil Jackson
12-11-2009, 05:05 PM
hmmm firebug seems to show:



<div id="div1" rel="nbta" style="border: 1px solid red; display: block; position: absolute; top: 0pt; left: 0pt; z-index: 1;"> </div>
<div id="div2" rel="nbta" style="border: 1px solid red; display: block; position: absolute; left: 0pt; z-index: 1;"> </div>
<div id="div3" rel="nbta" style="border: 1px solid red; display: block; position: absolute; left: 0pt; z-index: 1;"> </div>
<div id="div4" rel="nbta" style="border: 1px solid red; display: block; position: absolute; left: 0pt; z-index: 1;"> </div>

Phil Jackson
12-11-2009, 05:08 PM
sorted it... changed it to single quotes.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum