I am having a <div> with <a>s and <div>s inside it.
I am trying to read in all the elements in the right order.
With mydiv.getElemen tsByTagName("a" ) I can get the elements of a specific
tag like "a", but I want all types.
I tried getChildNodes but that doesn't seem to be widely supported.
childNodes[] seemed to do something but I couldn't get it working when I
wanted to browse through the elements.
What is the best way to do this?
A related question. If I have an element, how can I see which type (a, div,
input,etc) it is?
Thanks,
Wim 3 2093
On Sat, 18 Sep 2004 18:39:13 +0200, Wim Roffal
<wi************ *@nospamm-planet.nl> wrote:
[snip] I tried getChildNodes but that doesn't seem to be widely supported.
Probably because it doesn't exist. It's not part of Microsoft's DOM, or
the standardised W3C DOM (unless it's in Level 3).
childNodes[] seemed to do something but I couldn't get it working when I wanted to browse through the elements.
What is the best way to do this?
Mind showing what you were trying to do? The childNodes collection is your
best bet.
A related question. If I have an element, how can I see which type (a, div, input,etc) it is?
Use the nodeName property. This will return a case-sensitive string with
the element name. In HTML, the string will always be in uppercase.
Hope that helps,
Mike
--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Michael Winter wrote: On Sat, 18 Sep 2004 18:39:13 +0200, Wim Roffal <wi************ *@nospamm-planet.nl> wrote:
[snip]
I tried getChildNodes but that doesn't seem to be widely supported.
Probably because it doesn't exist. It's not part of Microsoft's DOM, or the standardised W3C DOM (unless it's in Level 3).
childNodes[] seemed to do something but I couldn't get it working when I wanted to browse through the elements.
What is the best way to do this?
Mind showing what you were trying to do? The childNodes collection is your best bet.
To help you out, childNodes returns a collection,
you can do something like:
var a = document.getEle mentById('aDiv' ).childNodes;
for (var i=0; i<a.length; ++i) {
// do something to each child
}
Other useful methods are firstChild and nextSibling - which is
really useful if you start at some unknown point in a DOM and
just want the next sibling. Say you want to find the next one
after "a" above without having to find the parentNode, work out
the index of "a", then get the next one. It's all
done by "var b = a.nextSibling". A related question. If I have an element, how can I see which type (a, div, input,etc) it is?
Use the nodeName property. This will return a case-sensitive string with the element name. In HTML, the string will always be in uppercase.
There is also nodeType, but different browsers seem to put
different node types in some places so it may not be that
useful for you.
Cheers, Fred.
On Sun, 19 Sep 2004 16:02:50 +1000, Fred Oz <oz****@iinet.n et.auau> wrote:
[snip] On Sat, 18 Sep 2004 18:39:13 +0200, Wim Roffal <wi************ *@nospamm-planet.nl> wrote:
[snip] A related question. If I have an element, how can I see which type (a, div, input,etc) it is?
[snip]
There is also nodeType, but different browsers seem to put different node types in some places so it may not be that useful for you.
The nodeType property doesn't return the information the OP wanted,
though. It returns quite literally the type: element, comment, DOCTYPE,
text, etc. However, that information does prove very useful when iterating
through the tree when looking for generic types. If you're looking for a
specific element, such as an INPUT, there isn't much need for it.
Mike
--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: mike420 |
last post by:
In the context of LATEX, some Pythonista asked what the big
successes of Lisp were. I think there were at least three *big*
successes.
a. orbitz.com web site uses Lisp for algorithms, etc.
b. Yahoo store was originally written in Lisp.
c. Emacs
The issues with these will probably come up, so I might as well
mention them myself (which will also make this a more balanced
|
by: Eyal |
last post by:
Hey,
I would appriciate if anyone can help on this one:
I have a java object/inteface having a method with a boolean
parameter. As I'm trying to call this method from a javascript it
fails on a type mismatch.
It is positively because of the boolean(java primitive)parameter. It
goes fine if I change this parameter to int or String.
This inteface has a lot more methods which works fine, it is just the
|
by: Todd Cary |
last post by:
In my previous post, I stated that some JavaScript I inherited does not
work in Firefox but does work in IE 6 . I have now isolated a line where it fails in Firefox; the
line with the property of "children".
function InitMenu()
{
if (document.all)
{
}
else
|
by: Luke Dalessandro |
last post by:
I'm not sure if this is the correct forum for platform specific
(Mozilla/Firefox) javascript problems, so just shout and point me to the
correct newsgroup if I'm being bad.
Here's the deal...
html file (generated using .NET 2.0 beta2):
<form method="post" action="Test2.aspx" id="form1">
|
by: Sunny |
last post by:
Hi All,
I have a serious issue regarding classes scope and
visibility. In my application, i have a class
name "TextFile", and also a few other classes
like "TotalWords", "TotalLines" and etc.., which are
suppose to describe the structure of my main TextFile
class. Also i have created some custom collection classes,
which only take items of the types, they are designed for.
Now the problem is that I want my element classes,
like...
| |
by: Richard Blewett [DevelopMentor] |
last post by:
I've just seen on Eric Gunnerson's blog that C# is getting Edit and Continue in Whidbey. That will please alot of people - although me, I have mixed feelings about it ;-)
http://blogs.msdn.com/ericgu/archive/2004/10/15/242931.aspx
Regards
Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog
|
by: Andrej Pavlovic |
last post by:
Hi,
Please look at the following HTML snippet:
<body>
some text
<p>more text</p>
even more text
</body>
|
by: Andrew May |
last post by:
This is only my first AJAX based application so this may be a trivial
question but I cannot find any way of getting at the data I want.
So, I have an XML file of the form:
<data>
<dataelement// one or more instances of this
|
by: Sin Jeong-hun |
last post by:
Hello.
Speical folders, like Desktop, usually have different display names.
For example, in Japanese Windows, it's displayed as "$B%G%9%/%H%C%W(B". I want
to get the this displayed name of a special folder but I can't find a
suitable method. Environment.GetFolderPath() is to get the path not
the name. There's no way provided the .NET BCL?
I also tried to get it through Win32 API. I looked up the MSDN site...
|
by: duane.lortie |
last post by:
I'm writing a routine that fetches XML and attempts to parse some
values from it.
A condensed entry node of the XML looks like this ..
<entry>
<title>Some title</title>
<author>
<name>Author</name>
</author>
<source:resource url="http://somesite.com?tid=123456"/>
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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,...
|
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...
|
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();...
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |