Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > How to determine outer DIV tag

Reply
Thread Tools

How to determine outer DIV tag

 
 
Spadar Programmer
Guest
Posts: n/a
 
      06-20-2007
Hello, everyone!

I'm trying to solve the next problem.
There's some HTML code. For example:

<div id="some_div">
...
<script type="text/javascript">
var oParentTag = getParentTag('some_div');
</script>
...
</div>

And my question: is there anything way to get the parent tag without
passing argument to the function in this case? Can JavaScript
atomatically determine the placement tag for executed script?

Regards, Yury Ksenevich (Spadar Programmer)

 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      06-20-2007
Spadar Programmer wrote:

> <div id="some_div">
> ...
> <script type="text/javascript">
> var oParentTag = getParentTag('some_div');
> </script>
> ...
> </div>
>
> And my question: is there anything way to get the parent tag without
> passing argument to the function in this case? Can JavaScript
> atomatically determine the placement tag for executed script?


If the script is global code then it is being executed while the page is
loaded and parsed meaning in that case
var divs = document.getElementsByTagName('div');
var lastDiv = divs[divs.length - 1];
should give you the div preceding the script element.




--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
FF 3.6 vs IE7 -- clicking on inner DIV causing outer DIV onBlur tofire in FF not in IE Tom Y Javascript 1 07-12-2011 08:36 AM
style of inner div is not overriding that of outer div Mc Lauren Series HTML 3 02-13-2010 01:36 AM
Can you format table contents from an outer DIV tag? bradsalmon HTML 6 10-13-2006 09:29 PM
Select text within a div tag by clicking on content of div tag? M Wells Javascript 0 10-06-2004 11:04 AM



Advertisments