473,809 Members | 2,633 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to retrieve an element from another DOM element

Frinavale
9,735 Recognized Expert Moderator Expert
Is there a method like document.getEle mentByID() which will retrieve an element from another DOM element?

Rephrasing: Say I retrieve a Div element using the getElementID method, is there a method to retrieve an element from within that element?
Mar 4 '09 #1
4 1287
acoder
16,027 Recognized Expert Moderator MVP
Yes, getElementsByTa gName() and getElementsByNa me(). These will return an array, so you just need to index them, e.g.
Expand|Select|Wrap|Line Numbers
  1. elem.getElementsByTagName("a")[0]
returns the first link element within elem.

Edit: also see Navigating nodes
Mar 4 '09 #2
Frinavale
9,735 Recognized Expert Moderator Expert
Thanks acoder
Mar 4 '09 #3
acoder
16,027 Recognized Expert Moderator MVP
It's actually getElementsByNa me(). Having said that though, it wouldn't work here because it's a method of document only unlike getElementsByTa gName(). You can also use the childNodes property. With some newer browsers, you can also use getElementsByCl assName().
Mar 4 '09 #4
Frinavale
9,735 Recognized Expert Moderator Expert
You can use the $find method if developing with the .NET Ajax Framework.
Mar 17 '09 #5

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

Similar topics

5
11202
by: David Rasmussen | last post by:
Some sites seem to be session driven in the sense that if I visit the homepage and do a few clicks I can navigate anywhere I want, but if I paste the current location into a new browser window after having navigated to some page, it doesn't work. It just returns to the start page or says "timeout" etc. This means that I can't read these pages from PHP with $string = file_get_contents('http://some.url/blah/deep/link');
3
1659
by: Cui | last post by:
Hi, and sorry for my poor english I have dynamically created some checkbox in a table, and I have also attached to it some event. mycurrent_cell = document.createElement("TD") ; chbox = document.createElement("INPUT") ; chbox.type = "CHECKBOX" ; chbox.name = "CHB_" & col_i ; // col_i is an integer.... chbox.attachEvent("onclick", chbox_click) ;
2
2494
by: Joe | last post by:
Hi I am going to receive a dataset downstream and I will not know the the fields number of field relations number of relations So I have to be flexible to take unknown data and be able to summarize all the info being passed
1
1582
by: mflll | last post by:
How does one say in one schema that one wants an element defined in another schema. For example, I want to include in the Employee definition, an Address element defined in the schema http://test.org.Address Here is the schema defining the Employee: <?xml version="1.0" encoding="UTF-8"?> <xsd:schema targetNamespace="http://test.org/emp" xmlns="http://test.org/emp"
6
3873
by: ashok.dhananjeyan | last post by:
Hi, Actually , I wrote one javascript to retrieve the name of the form in one particular page. what i did in this page is, <script> function checkbutton() {
2
1283
by: dmorand | last post by:
Is it possible to retrieve css style's using javascript? I have an element which I've setup to not display when the page loads using display:none; I want to retrieve the display value for the element and then change it based on what it is. I've tested this, and when I call hideshow the first time, there's no value for style.
7
2691
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= | last post by:
I have a C# logging assembly with a static constructor and methods that is called from another C# Assembly that is used as a COM interface for a VB6 Application. Ideally I need to build a file name based on the name of the VB6 application. A second choice would be a file name based on the # COM interface assembly. I have tried calling Assembly.GetCallingAssembly() but this fails when I use the VB6 client. Is there a way to get this...
1
6431
by: Elliot | last post by:
When decrypt the xml, output "Unable to retrieve the decryption key." Can anyone help me solve the problem? I got the code from http://msdn.microsoft.com/en-us/library/ms229746.aspx using System; using System.Xml; using System.Security.Cryptography; using System.Security.Cryptography.Xml;
3
7231
by: drajani | last post by:
I have the below input XML sent by APP1. <?xml version="1.0" encoding="UTF-8"?> <abc1:QWAARequest xmlns:abc1="http://www.mysite.com/myLink/v1/Test.xsd" xmlns:abc2="http://www.mysite.com/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mysite.com/myLink/v1/Test.xsd Test.xsd"> <abc1:HostID>TEST</abc1:HostID> <abc1:WorkForceEvent>
0
10640
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10387
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10120
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9200
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5689
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.