473,320 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How can you get the top level div?

YenRaven
heres my problem... I have some divs nested like this
Expand|Select|Wrap|Line Numbers
  1. <div id="divID"><div><a href="someplace">Some place</a></div><div><a href="Someplaceelse">Some Other place</a></div></div>
the divs are controled through a combination of css and javascript. I use some code like this in my script:
Expand|Select|Wrap|Line Numbers
  1. function clicktest(e){
  2.     if (!e) var e = window.event
  3.     if (e.target) targ = e.target
  4.     else if (e.srcElement) targ = e.srcElement
  5.     if (targ.nodeType == 3) // defeat Safari bug
  6.        targ = targ.parentNode
  7.     var tname
  8.     tname=targ.tagName
  9.     alert(targ.id)
All i need is for the alert to show the top level divs id not the children divs.
thanks in advanced for any help.
Oct 20 '06 #1
1 3239
hi,

i saw your post and i tried a piece of code. This code works, if you are calling the fucnction from one of the child object's.

Expand|Select|Wrap|Line Numbers
  1. function findParentDiv(objName){
  2.     var parentName;
  3.     while(objName!=null && objName.tagName!='BODY'){
  4.         if(objName.tagName=='DIV'){
  5.             var parentName = objName.id;
  6.         }
  7.         objName = objName.parentElement;
  8.     }
  9.     alert(parentName);
  10. }
the objName that you pass as parameter to the function is the child object from which you are calling the function.
Oct 31 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: mike | last post by:
best regards: What is the difference between DOM Level 1 and DOM Level 2. Thank you. May god be with you.
3
by: Ais | last post by:
Hi.. Presently i'm trying to install IBM Db2 Software on my Windows XP Operating systems. I'm using IBM(R) DB2(R) Universal Database Enterprise Server Edition, Version 8.1. After...
3
by: Eric Porter | last post by:
Dear All, I have a VB6.COM program using a VB6.COM DLL, which in turn uses ADODB that performs various bits of SQL. I have re-written the VB6.COM DLL in C#.NET (with a VB6 shell), which uses...
2
by: kanda | last post by:
Hello. I am developing the application (VBA&ODBC, to be exact) which periodically calls the stored procedures in the IBM DB2. A few of the procedures require executing with isolation level RR (...
2
by: RanjitSingh.RS | last post by:
I have several Databases in a Instance . I want to a set particular Isolation Level for Only one read Only Database . Is it Possible to set a specific Isloation Level at a Database Level
6
by: GrispernMix | last post by:
//ques and and level order traversal file name: lab6_build_leaf_up.cpp Instructions:
7
by: GrispernMix | last post by:
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <conio.h> #include <iostream> #include <string.h> using namespace std; #define TRUE 1 #define FALSE 0
1
by: Ruth413 | last post by:
Hello - I am getting the these errors in my sql 2005 generated script. I am stuck with first error. Please help.... Msg 102, Level 15, State 1, Line 3 Incorrect syntax near '('. Msg 319,...
6
by: gskbond | last post by:
Following is my logic to traverse level by level an mway search tree.... (Yeah I finally used templates to implement a queue... :) ) void mWayTree:: TraverseLevelOrder(Node *root,int lvl) {...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.