How do I capture the Id of a parent HTML element that won't be known until runtime?
I have an ASP.NET control that spits out <span> elements and I won't know their Ids until the ASP.NET code is compiled.
<div id ="mydiv"> some text
var data = document.getElementById('div2').getAttribute('id');
Can someone please tell me how to accomplish this?
how will this:
ever return anything but "div2"?
you should look at something like
You want the parent node's id of this script tag?
var els = document.getElementsByTagName("script"),
data = els[els.length-1].parentNode.id;
Last edited by Declan1991; 05-13-2012 at 07:22 PM.
Great wit and madness are near allied, and fine a line their bounds divide.
Declan, your code does the trick Thanks a lot
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)