Jump to content

Parent, Child Getelementbyid() -)poke(-


ckrudelux

Recommended Posts

How do I select a specific parents child?

document.getElementById('parent').getElementByClass('first_child')

<div id="parent"><div class="first_child"></div></div><div id="another_parent"><div class="first_child"></div></div>

Link to comment
Share on other sites

1. You have the right idea, but the wrong method name. What you want is parent.getElementsByClassName(). Notice that elements is plural, because it returns a collection.2. Unfortunately, it is not supported by IE. So we won't seriously be using it for 8-10 years, which is a shame, because it is very useful.3. Go back to old techniques. Get a collection of elements by tagname, loop through it and test for className. Then, I suppose, the first element that matches is your target.4. Or maybe you were using classes as an example, and you want a more general technique that gets the first child of a parent, no matter what its tag or class is?5. In that case, use the parent.childNodes collection. It is available in all modern browsers. Loop through it until you find the first node whose nodeType is 1. That loop and filter is needed because the childNodes collection contains text nodes that are full of all your formatting text (returns, tabs, spaces, etc), and you don't want to get that stuff.6. This process will be old fashioned when all browsers implement the parent.children collection, which specifically excludes text nodes. Older versions of FF (before 3.5) do not support it. I personally do not risk using it yet for this reason.7. What you really really want is parent.firstElementChild, which likewise excludes text nodes . So it is like the technique I describe in #5 above. It is supported widely, but not by IE at all. So forget about that one for a while, too.

Link to comment
Share on other sites

I'm trying to get the order of some object and save the order to my database. I got some parents and child objects.

<div class="parent">	<input type="hidden" name="id" value="10" />		<div class="child">		<input type="hidden" name="id" value="64" />	</div>	<div class="child">		<input type="hidden" name="id" value="53" />	</div></div><div class="parent">	<input type="hidden" name="id" value="15" />		<div class="child">		<input type="hidden" name="id" value="12" />	</div>	<div class="child">		<input type="hidden" name="id" value="76" />	</div></div>script runs and get this order:10{64,53}15{12,76}<div class="parent">	<input type="hidden" name="id" value="15" />		<div class="child">		<input type="hidden" name="id" value="64" />	</div>	<div class="child">		<input type="hidden" name="id" value="76" />	</div></div><div class="parent">	<input type="hidden" name="id" value="10" />		<div class="child">		<input type="hidden" name="id" value="12" />	</div>	<div class="child">		<input type="hidden" name="id" value="53" />	</div></div>run script again15{64,76}10{12,53}

Link to comment
Share on other sites

var allDivs = document.getElementsByTagName('div')// if the elements are in a form or some other common ancestor, you can save processor time by using:var allDivs = myAncestor.getElementsByTagName('div')// now loop through allDivs and testif (className == 'parent')// if a div matches, usemyInputs = allDivs.getElementsByTagName['input']// loop through myInputs.// myInputs[0] will return '10' or '15' in the examples in your post// all other members of myInputs will be the children you want to put in the {}// if you have other inputs that must be eliminated, testif (myInputs.parentNode.className == 'parent')// remember this is a loop in a loop, so you will eventually cycle through all the elements you are interested in.

Link to comment
Share on other sites

var allDivs = document.getElementsByTagName('div')// if the elements are in a form or some other common ancestor, you can save processor time by using:var allDivs = myAncestor.getElementsByTagName('div')// now loop through allDivs and testif (className == 'parent')// if a div matches, usemyInputs = allDivs.getElementsByTagName['input']// loop through myInputs.// myInputs[0] will return '10' or '15' in the examples in your post// all other members of myInputs will be the children you want to put in the {}// if you have other inputs that must be eliminated, testif (myInputs.parentNode.className == 'parent')// remember this is a loop in a loop, so you will eventually cycle through all the elements you are interested in.
Everything is in a div so could I write the id of that div instead of myform?
Link to comment
Share on other sites

Yup. Just try it. That's how I've learned most of what I know.
Well I don't code so much javascript and I haven't really got the structure of javascript in the way I do when I code in php.
Link to comment
Share on other sites

Well I don't code so much javascript and I haven't really got the structure of javascript in the way I do when I code in php.
I too used to be this way (in fact, I still don't like JavaScript, and try to minimize my work with it). Fortunatly, the thing that helped me, and which I think will help you is that there is DOM in PHP. It's not as rich as the one in JavaScript, but it's much more bug free, and easier to trace, so I highly reccomend you get comfy with that, and only then go back to JavaScript.
Link to comment
Share on other sites

I too used to be this way (in fact, I still don't like JavaScript, and try to minimize my work with it). Fortunatly, the thing that helped me, and which I think will help you is that there is DOM in PHP. It's not as rich as the one in JavaScript, but it's much more bug free, and easier to trace, so I highly reccomend you get comfy with that, and only then go back to JavaScript.
I will look in to what. :)
Link to comment
Share on other sites

Whatever language you experiment in, don't do it with a work in progress. Create a special document where you can learn about one technique at a time. Maybe it uses a snippet of your current project, maybe not. The point is to master a technique without messing up something important. Then, when you are confident with it, go back and apply it to your real project. (Or not, if it turns out the technique doesn't work.) Even then, try it on a copy of your document, so you can always go back to a version that isn't broken. I have snippets ALL OVER my desktop and development server.

Link to comment
Share on other sites

Whatever language you experiment in, don't do it with a work in progress. Create a special document where you can learn about one technique at a time. Maybe it uses a snippet of your current project, maybe not. The point is to master a technique without messing up something important. Then, when you are confident with it, go back and apply it to your real project. (Or not, if it turns out the technique doesn't work.) Even then, try it on a copy of your document, so you can always go back to a version that isn't broken. I have snippets ALL OVER my desktop and development server.
Yes so far I know what to do I allways use a new file to test on.. Btw I don't get the id to work.main.getElementsByTagName('div')main is the id for the div everything is in.
Link to comment
Share on other sites

If you want a serious analysis of the problem, you'll have to post a big chunk of code, along with relevant HTML. Parent-child relationships can easily get confused, and my description of the process might easily have missed something.alert() can sometimes be your best friend in situations like this.

Link to comment
Share on other sites

If you want a serious analysis of the problem, you'll have to post a big chunk of code, along with relevant HTML. Parent-child relationships can easily get confused, and my description of the process might easily have missed something.alert() can sometimes be your best friend in situations like this.
Well I have an alert.every things looks like the example above width divs but they have a div around them called main
<div id="main">The divs above.</div>

I have a button calling the function.

function name(){	var allDivs = main.getElementsByTagName('div');	alert(allDivs[0].className);}

Then I press the button noting happens if I change main to document it works.

Link to comment
Share on other sites

"document" is not an ID of an element. It's a predefined JavaScript object. That's why it works."main" is not an element with a certain ID either. It's a non existant object in this case. You need to manually fetch it first.Try this:

function name(){	var main = document.getElementById('main');	var allDivs = main.getElementsByTagName('div');	alert(allDivs[0].className);}

Link to comment
Share on other sites

"document" is not an ID of an element. It's a predefined JavaScript object. That's why it works."main" is not an element with a certain ID either. It's a non existant object in this case. You need to manually fetch it first.Try this:
function name(){	var main = document.getElementById('main');	var allDivs = main.getElementsByTagName('div');	alert(allDivs[0].className);}

Thanks it works now :):)
Link to comment
Share on other sites

Two ways. They both involve some sort of loop filtering. parent.childNodes returns a collection of all children, including text nodes. You can loop through the collection and test for classNameparent.getElementsByTagName(tagName) returns a collection of children elements and their descendants. You can restrict the search by passing the name of an element (like 'div') in tagName. You can return ALL descendant elements by passing '*' in tagName. Remember to pass a string in quotation marks or a string assigned to a variable. You can loop through this collection also.The advantage to parent.childNodes is that it limits the search only to direct children. The disadvantage is that it also returns text nodes, which you almost never want. So you have to filter them out in your loop.The advantage to parent.getElementsByTagName is that it only returns page elements (no text nodes). But it also returns descendants, no matter how deeply nested they are. That can be good or bad, depending on your application.With either technique, you will probably need to do some loop filtering: by nodeName (or nodeType), className, or even parentNode.className

Link to comment
Share on other sites

Two ways. They both involve some sort of loop filtering. parent.childNodes returns a collection of all children, including text nodes. You can loop through the collection and test for classNameparent.getElementsByTagName(tagName) returns a collection of children elements and their descendants. You can restrict the search by passing the name of an element (like 'div') in tagName. You can return ALL descendant elements by passing '*' in tagName. Remember to pass a string in quotation marks or a string assigned to a variable. You can loop through this collection also.The advantage to parent.childNodes is that it limits the search only to direct children. The disadvantage is that it also returns text nodes, which you almost never want. So you have to filter them out in your loop.The advantage to parent.getElementsByTagName is that it only returns page elements (no text nodes). But it also returns descendants, no matter how deeply nested they are. That can be good or bad, depending on your application.With either technique, you will probably need to do some loop filtering: by nodeName (or nodeType), className, or even parentNode.className
So this is my script so far and I get 0 hits then I try to find child objects
function savearray(){	var main = document.getElementById('main');	var allDivs = main.getElementsByTagName('div');	var pi = 0;	for(pi=0; pi < allDivs.length; pi++){		if(allDivs[pi].className == "areaweight"){			alert(allDivs[pi].className);						var ci = 0;			var elements = allDivs[pi].getElementsByTagName('div');			alert(elements.length); // 0 results			for(ci=0; ci < elements.length; ci++){				if(elements[ci].className == "moduleweight"){					alert(elements[ci].className);				}			}		}	}}

Link to comment
Share on other sites

You'll have to post the HTML that goes with this.
What's a bit hard.. so the best way I can give you the code is by copy paste the browser source code.
<!DOCTYPE html>	<head>							<meta name="product" content="pagemodule 2.0" />		<meta http-equiv="Content-Type" content="text/xml; charset=ISO-8859-1" />		<meta name="description" content="PageModule 2.0" />		<meta name="keywords" content="PageModule 2.0" /> 							<title>			PageModule 2.0		</title>							<link rel="stylesheet" type="text/css" href="style.php" />				<script type="text/javascript" src="jquery-1.3.2.js"></script>		<script type="text/javascript" src="ui/jquery-ui-1.7.2.custom.js"></script>		<script type="text/javascript" src="ui/ui.core.js"></script>		<script type="text/javascript" src="ui/ui.sortable.js"></script>		<script type="text/javascript" src="ui/ui.resizable.js"></script>		<script type="text/javascript" src="ui/ui.draggable.js"></script>											<link rel="stylesheet" type="text/css" href="css/paragraph.css" />									<link rel="stylesheet" type="text/css" href="css/ui.core.css" />									<link rel="stylesheet" type="text/css" href="css/ui.resizable.css" />									<link rel="stylesheet" type="text/css" href="css/ui.theme.css" />									<script type="text/javascript" src="js/clearcontent.js"></script>									<script type="text/javascript" src="js/dragdrop.js"></script>									<script type="text/javascript" src="js/getXMLHttp.js"></script>									<script type="text/javascript" src="js/request.js"></script>									<script type="text/javascript" src="js/resize.js"></script>									<script type="text/javascript" src="js/savearray.js"></script>									<script type="text/javascript" src="js/showhide.js"></script>					</head><body>			<div id="admin_menu_background">		</div>		<div id="admin_menu">				<div class="admin_menu_middle">					<div style="float: left; margin: 0px 10px 0px 40px;">						<div style="float: left;">							<div id="left_text">														<div id="dropdown">																	<a class="admin_menu_link" href="?page=1">Start</a><br />																	<a class="admin_menu_link" href="?page=2">Kaktus</a><br />																	<a class="admin_menu_link" href="?page=7">test</a><br />																	<a class="admin_menu_link" href="?page=8">ÖL Listan</a><br />																</div>							</div>							<div id="middle_text">Start</div>							<div id="right_text"></div>						</div>					</div>					<img onclick="window.location.href='communicate.php?main=1'" class="admin_menu_button" title="Select As Start Page" alt="Select As start Page" src="graphic/admin_menu/main/main.png" />					<img onclick="showhide('adminpopup'); MakeRequest({method: 'get', url: 'settings.php', callback: HandleResponse, params: {type: 'addpage', name: 'Page', pid: '1',}});" class="admin_menu_button" title="Add Page" alt="Add Page" src="graphic/admin_menu/main/add.png" />					<img onclick="showhide('adminpopup'); MakeRequest({method: 'get', url: 'settings.php', callback: HandleResponse, params: {type: 'addarea', name: 'Area', pid: '1',}});" class="admin_menu_button" title="Add Area To Page" alt="Add Area To Page" src="graphic/admin_menu/main/addarea.png" />					<img onclick="savearray();" class="admin_menu_button" title="Users" alt="Users" src="graphic/admin_menu/main/users.png" />					<img onclick="showhide('adminpopup'); MakeRequest({method: 'get', url: 'settings.php', callback: HandleResponse, params: {type: 'pagesettings', name: 'Page Settings', pid: '1',}});" class="admin_menu_button" title="Page Settings" alt="Page Settings" src="graphic/admin_menu/main/settings.png" />					<img class="admin_menu_button" title="Delete Page" alt="Delete Page" src="graphic/admin_menu/main/delete.png" />					<img onclick="window.location.href='logout.php';" class="admin_menu_button" title="Logout" alt="Logout" src="graphic/admin_menu/main/logout.png" />				</div>		</div>		<div id="adminpopup">		</div>		<div id="main" class="main" style="float: left; width: 100%;">				<div class="areas connectedSortable grid12 left">	<div class="areaweight">		<input type="hidden" name="" value="1" />	</div>	<div class="adminmenulist" style="float: left; margin-top: 10px; width: 100%; background: url('graphic/admin_menu/module_area/list.png');">	<div class="adminmainicon adminmoveicon movearea"></div>	<div class="adminmainicon admindeleteicon"></div>	<div class="adminmainicon adminsettingsicon" onclick="showhide('adminpopup'); MakeRequest({method: 'get', url: 'settings.php', callback: HandleResponse, params: {type: 'area', name: 'Area', aid: '1', pid: '1'}});"></div>	<div class="adminmainicon adminaddicon" onclick="showhide('adminpopup'); MakeRequest({method: 'get', url: 'settings.php', callback: HandleResponse, params: {type: 'addmodule', name: 'Module', aid: '1',}});"></div></div>					<div class="moduleweight" style="float: left; width: 100%;">					<input type="hidden" name="" value="2" />					<div style="position: absolute; z-index: 5;">	<div class="adminmainicon adminmoveicon movemodule"></div>	<div class="adminmainicon admindeleteicon"></div>	<div class="adminmainicon adminsettingsicon" onclick="showhide('adminpopup'); MakeRequest({method: 'get', url: 'settings.php', callback: HandleResponse, params: {type: 'module', name: 'Banner', directory: 'banner', mid: '1',}});"></div></div><img alt="" style="float: left; width: 100%;" src="graphic/banner/banner.jpg" />					</div>										<div class="moduleweight" style="float: left; width: 100%;">					<input type="hidden" name="" value="3" />					<div style="position: absolute; z-index: 5;">	<div class="adminmainicon adminmoveicon movemodule"></div>	<div class="adminmainicon admindeleteicon"></div>	<div class="adminmainicon adminsettingsicon" onclick="showhide('adminpopup'); MakeRequest({method: 'get', url: 'settings.php', callback: HandleResponse, params: {type: 'module', name: 'Spacer', directory: 'spacer', mid: '1',}});"></div></div><div style="float: left; width: 100%; height: 30px; margin: 5px 0px 5px 0px; background: #000;"></div>					</div>									</div>					<div class="areas connectedSortable grid7 left">	<div class="areaweight">		<input type="hidden" name="" value="2" />	</div>	<div class="adminmenulist" style="float: left; margin-top: 10px; width: 100%; background: url('graphic/admin_menu/module_area/list.png');">	<div class="adminmainicon adminmoveicon movearea"></div>	<div class="adminmainicon admindeleteicon"></div>	<div class="adminmainicon adminsettingsicon" onclick="showhide('adminpopup'); MakeRequest({method: 'get', url: 'settings.php', callback: HandleResponse, params: {type: 'area', name: 'Area', aid: '2', pid: '1'}});"></div>	<div class="adminmainicon adminaddicon" onclick="showhide('adminpopup'); MakeRequest({method: 'get', url: 'settings.php', callback: HandleResponse, params: {type: 'addmodule', name: 'Module', aid: '2',}});"></div></div>					<div class="moduleweight" style="float: left; width: 100%;">					<input type="hidden" name="" value="4" />					<div style="position: absolute; z-index: 5;">	<div class="adminmainicon adminmoveicon movemodule"></div>	<div class="adminmainicon admindeleteicon"></div>	<div class="adminmainicon adminsettingsicon" onclick="showhide('adminpopup'); MakeRequest({method: 'get', url: 'settings.php', callback: HandleResponse, params: {type: 'module', name: 'Paragraph', directory: 'paragraph', mid: '1',}});"></div></div><div style="float: left; width: 100%; background: #fff;"><h1 style="margin: 20px 10px 2px 10px">	Drifting 101	</h1>	<p style="margin: 0px 10px 0px 10px; padding: 0px 60px 0px 60px;">	Det första du behöver för att lära dig att drift:a är en större öppen yta där du inte riskerar att köra in i något. Val av vägunderlag gör det olika svårt och kostsamt.<br />	De olika vägunderlagen är: Snö, Grus, asfalt och blöt asfalt.<br />	<br />	Snö:<br />	Bra att lära sig när man är nybörjare, då det är lite friktion och sliter väldigt lite på däcken, kräver dock att det är vinter.<br />	<br />	Grus:<br />	Också en bra yta att lära sig på, kan dock vara skadligt för din bil då grus har en förmåga att vara hård och sprätta runt lite överallt när man drift:ar på det.<br />	<br />	Asfalt:<br />	Sliter på dina däck och har mer friktion än vad snö och grus har vilket gör det svårare att få sladd.<br />	<br />	Blöt asfalt:<br />	Blöt asfalt sliter på däcken men inte lika mycket  som torr och är lättare att få sladd på. Blöt därför ner asfalten som nybörjare för att underlätta träningen.<br />	<br />	Vilken Bil Ska Jag Använda?<br />	Bilen bör vara bakhjulsdriven men det funkar med 4 hjuls drift också. Framhjuls drift går det med men inte lika kul och anses på vissa plan att det inte räknas som riktigt drifting.<br />	<br />	Drifting kan göras med nästa vilken bil bakhjulsdriven som helst, kräver dock olika mycket teknik att lyckas vägunderlaget spelar stor roll också då det kräver starkare motorer att lyckas drift:a på vägytor med högre friktion än de med mindre.<br />	</p>	<h1 style="margin: 20px 10px 2px 10px">Olika Tekniker</h1>	<p style="margin: 0px 10px 0px 10px; padding: 0px 60px 0px 60px;">	Handbrake Drift:<br />	När du kör in i kurvan så trycker du ner kopplingen styr i kurvans riktning drar i handbromsen tillför lite gas och släpp samtidigt på handbromsen och styr emot.<br />	<br />	Vad som händer är att när du börjar styra så belastas däcken och när du drar i handbromsen så blir belastningen högre än vad däcken orkar hålla kvar i det här fallet bakdäcken. Detta resulterar i att  bakdelen av bilen glider ut och du kan släppa handbromsen och tillföra gas för att hålla kvar bilen i ställ och balansera genom att styra emot.<br />	<br />	Clutch Kick:<br />	När du kommer in mot kurvan trycker du ner kopplingen gasar upp och släpper kopplingen samtidigt som du svänger mot kurvans riktning. Styr emot när du får ut bakdelen av bilen.<br />	<br />	Det som händer är att när du släpper kopplingen har motorn mycket högre varv vilket resulterar i att den har mer kraft att lägga på bakhjulen och tappar oftast i det läget fäste.<br />	<br />	Feint Drift:<br />	Här kommer du använda bilens rörelse energi. När du kommer in mot kurvan så styr du först mot den motsatta riktningen av kurvan och sen i kurvans riktning där efter styr du emot.<br />	<br />	Vad som händer är att rörelse energin vill först flytta sig mot kurvans motsatta håll och när du styr tillbaka till kurvans riktning så får du ett eftersläng alltså bakdelen fortsätter mot kurvans yttre del och framdelen drar sig mot den inre delen av kurvan och bakdäcken tappar fäste.<br />	<br />	Inertia Drift:<br />	Här kommer du använda dig av bilens rörelse energi igen. När du kommer in mot kurvan bromsar du hårt och styr i kurvans riktning släpp på bromsen och tillför gas samt styr emot.<br />	<br />	Det som händer är att när du bromsar flyttas all rörelse energi fram till framhjulen och när du gasar igen så släpper bakdäcken för att du minskat på friktionen.<br />	<br />	Power Over:<br />	Enkelt men behöver en ganska så stark bil då du tvingar ut bilen i sladd genom att bara gasa för mycket. Ungefär som Clutch Kick men i Clutch Kick så bygger du upp ett högre vridmoment när motorn inte belastar däcken.<br /></p><h1 style="margin: 20px 10px 2px 10px">Första Drift:en</h1><p style="margin: 0px 10px 20px 10px; padding: 0px 60px 0px 60px;">	Det första du kommer att göra är att träna in balansen av gas och styrning samt känna av gränsen av  hur mycket tryck däcket orkar med innan den tappar för mycket fäste.<br />	<br />	Beroende på vilket underlag du har blir första steget lite olika. På snön den bästa ytan för en nybörjare.<br />	<br />	Börja i låg ###### och testa gasa lite i kurvan för att känna hur mycket gas som krävs för att däcken ska tappa fäste. Försök än så länge inte med någon drift utan försök följa kurvan runt som du skulle köra runt den vanligt och känn bara efter vart bilen börjar tappa fäste.<br />	<br />	När du gjort det här några gånger kommer du märka att du kommer köra bredare och bredare kanske lite fortare också, det som du gör nu är att du känner in balansen av bilen någon gång under de här försöken kommer du kanske gasa för mycket och bilen kommer att fortsätta runt. Om det inte hänt ännu kan du testa göra det med flit genom att tillföra för mycket gas.<br />	<br />	När bilen hamnar i sladd kommer du kunna känna vart bilen är på väg. Det är bra att veta hur det ska kännas när du försöker de olika teknikerna  Samma sak där börja med lägre ###### och bara känn efter vart balansen ligger.<br />	<br />	Om du börjar på grus gäller samma grej som när du börjar i snö, men om du börjar på asfalt är det lite knepigare då är så mycket grepp att du antagligen inte bara kan gas dig ut i sladd.<br />	Förslag är att du testar med ett par dåliga däck som inte har lika mycket fäste och gärna på en blöt yta och allt efter som gå på torrare underlag. Det är viktigt att öva på lättare underlag då det inte gör så mycket om du skulle råka göra fel och minskar risken för att något skulle gå sönder.<br /></p></div>					</div>									</div>					<div class="areas connectedSortable grid5 left">	<div class="areaweight">		<input type="hidden" name="" value="3" />	</div>	<div class="adminmenulist" style="float: left; margin-top: 10px; width: 100%; background: url('graphic/admin_menu/module_area/list.png');">	<div class="adminmainicon adminmoveicon movearea"></div>	<div class="adminmainicon admindeleteicon"></div>	<div class="adminmainicon adminsettingsicon" onclick="showhide('adminpopup'); MakeRequest({method: 'get', url: 'settings.php', callback: HandleResponse, params: {type: 'area', name: 'Area', aid: '3', pid: '1'}});"></div>	<div class="adminmainicon adminaddicon" onclick="showhide('adminpopup'); MakeRequest({method: 'get', url: 'settings.php', callback: HandleResponse, params: {type: 'addmodule', name: 'Module', aid: '3',}});"></div></div>					<div class="moduleweight" style="float: left; width: 100%;">					<input type="hidden" name="" value="5" />					<div style="position: absolute; z-index: 5;">	<div class="adminmainicon adminmoveicon movemodule"></div>	<div class="adminmainicon admindeleteicon"></div>	<div class="adminmainicon adminsettingsicon" onclick="showhide('adminpopup'); MakeRequest({method: 'get', url: 'settings.php', callback: HandleResponse, params: {type: 'module', name: 'Paragraph 2', directory: 'paragraph2', mid: '1',}});"></div></div><div style="float: left; width:380px; height: 285px; background: url('graphic/images/drift1.jpg');"></div><div style="float: left; width:260px; padding: 5px 60px 5px 60px; margin: 10px 0px 10px 0px; background: #fff;">	Handbrake drift:<br />	Vid steg 1 drar du i hand bromsen när bilen står ungefär som i steg 2 släpper du handbromsen och tillför gas. Försök hålla driften till 3:e steget.<br />	<br />	Clutch Kick:<br />	Vid steg 1 trycker du ner kopplingen öka gaspådraget och släpp på kopplingen, nu borde bilen ha hamnat som i steg 2. Försök hålla driften till 3:e steget.<br />	<br />	Inertia Drift:<br />	Bromsa in hårt tills bilen hamnar som steg 1 och sen tillför du gas. Bilen borde hamna som i steg 2 sen är det bara att försöka hålla driften till 3:e steget<br />	<br />	Power Over:<br />	När bilen står som i steg 1 ger du full gas för att få ut bakdelen av bilen så den står som i steg 2. Försök hålla driften till 3:e steget<br /></div><div style="float: left; width:380px; height: 285px; background: url('graphic/images/drift2.jpg');"></div><div style="float: left; width:260px; padding: 5px 60px 5px 60px; margin: 10px 0px 10px 0px; background: #fff;">	Feint Drift:<br />	Från steg 1 styr du upp bilen till steg 2 där efter styr du in mot kurvan och ökar gaspådraget. Bilen borde få ut bakdelen och hamna som i steg 3. Nu är det bara att försöka hålla driften till 4:e steget.</div><div style="float: left; width:380px; height: 285px; background: url('graphic/images/drift3.jpg');"></div><div style="float: left; width:260px; padding: 5px 60px 5px 60px; margin: 10px 0px 10px 0px; background: #fff;">	När du gasar för mycket kommer bakdelen av bilen försöka fortsätta runt.</div><div style="float: left; width:380px; height: 285px; background: url('graphic/images/drift4.jpg');"></div><div style="float: left; width:260px; padding: 5px 60px 5px 60px; margin: 10px 0px 10px 0px; background: #fff;">	När du gasar för lite så kommer bilen att räta ut sig.</div>					</div>										<div class="moduleweight" style="float: left; width: 100%;">					<input type="hidden" name="" value="6" />					<div style="position: absolute; z-index: 5;">	<div class="adminmainicon adminmoveicon movemodule"></div>	<div class="adminmainicon admindeleteicon"></div>	<div class="adminmainicon adminsettingsicon" onclick="showhide('adminpopup'); MakeRequest({method: 'get', url: 'settings.php', callback: HandleResponse, params: {type: 'module', name: 'CommentBox', directory: 'commentbox', mid: '1',}});"></div></div><div style="float: left; margin: 10px 0px 10px 0px; width: 380px; background: #555;">	<form action="modules/commentbox/communicate.php" method="post">	<p style="margin: 5px 60px 20px 60px; color: #fff;">Kommentarer:</p>		<h2 style="margin: 10px 60px 2px 60px; color: #fff;">Andreas:</h2>	<p style="margin: 0px 60px 0px 60px; padding: 5px; border-left: 1px dashed #000; border-right: 1px dashed #000; color: #fff;">CMS: Pagemodule 2.0</p>		<h2 style="margin: 10px 60px 2px 60px; color: #fff;">:P:</h2>	<p style="margin: 0px 60px 0px 60px; padding: 5px; border-left: 1px dashed #000; border-right: 1px dashed #000; color: #fff;">COOL!</p>		<h2 style="margin: 10px 60px 2px 60px; color: #fff;">Anderas:</h2>	<p style="margin: 0px 60px 0px 60px; padding: 5px; border-left: 1px dashed #000; border-right: 1px dashed #000; color: #fff;">Nice</p>		<input style="float: left; margin: 20px 60px 0px 60px; width: 258px; border: 1px dashed #fff; background: #555;" type="text" name="name" />	<textarea style="float: left; margin: 5px 60px 5px 60px; width: 254px; max-width: 254px; height: 100px; border: 1px dashed #fff; background: #555;" name="comment"></textarea>	<input style="float: left; margin: 0px 60px 20px 60px; width: 260px; border: 1px solid #fff; background: #555;" type="submit" value="POST" />	</form></div>					</div>									</div>			</div></body></html>

Link to comment
Share on other sites

The structure your function implies is something like the following. When I use it with your function, I get all the alerted values you seem to expect. So the function works. It gets all the right collections, and it screens for the correct classNames, even more than one level deep. (The "nothing" divs do not get alerted, but a "moduleweight" contained by a "nothing" does get alerted.)Perhaps your structure does not look like this?

<div id="main">	<div class="nothing"></div>	<div class="areaweight">		<div class="moduleweight"></div>	</div>	<div class="areaweight">		<div class="nothing">			<div class="moduleweight"></div>		</div>		<div class="moduleweight"></div>		<div class="moduleweight"></div>		<div class="moduleweight"></div>	</div>	<div class="areaweight">		<div class="moduleweight"></div>	</div></div>

Link to comment
Share on other sites

The structure your function implies is something like the following. When I use it with your function, I get all the alerted values you seem to expect. So the function works. It gets all the right collections, and it screens for the correct classNames, even more than one level deep. (The "nothing" divs do not get alerted, but a "moduleweight" contained by a "nothing" does get alerted.)Perhaps your structure does not look like this?
<div id="main">	<div class="nothing"></div>	<div class="areaweight">		<div class="moduleweight"></div>	</div>	<div class="areaweight">		<div class="nothing">			<div class="moduleweight"></div>		</div>		<div class="moduleweight"></div>		<div class="moduleweight"></div>		<div class="moduleweight"></div>	</div>	<div class="areaweight">		<div class="moduleweight"></div>	</div></div>

Yes It should have what structure maybe I miss typed the class or put it in the wrong place.. couse then I test it on a new file it works like a clock.
Link to comment
Share on other sites

Yes It should have what structure maybe I miss typed the class or put it in the wrong place.. couse then I test it on a new file it works like a clock.
I just saw where the problem is... I moved the class to another div for some resons and the moduleweight is out side that div so I just have to move the end tag of the div :)
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...