473,659 Members | 3,277 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to find all elements starting with <text>

Hi,

I would like to find all elements within my DOM that begin with
"test". Any idea on how I would go about this?

Example Below I would like to return a list of element id's of test1,
test2, test3

<html>
<body>
<div id="spacer">
<div id="test1">Blah </div>
<div id="test2">Blah </div>
</div>
<div id="test3">Blah </div>
</body>
</html>

Aug 14 '07 #1
2 4852
bl****@worldweb .com wrote on 14 aug 2007 in comp.lang.javas cript:
Hi,

I would like to find all elements within my DOM that begin with
"test". Any idea on how I would go about this?

Example Below I would like to return a list of element id's of test1,
test2, test3

<html>
<body>
<div id="spacer">
<div id="test1">Blah </div>
<div id="test2">Blah </div>
</div>
<div id="test3">Blah </div>
</body>
</html>
Nice school assignmant, methinks.
Any idea on how I would go about this?
Sure, but it seeme better you explore the possiblilities yourself.

Advice: use a loop.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Aug 14 '07 #2
On Aug 15, 7:15 am, "bla...@worldwe b.com" <bla...@worldwe b.comwrote:
Hi,

I would like to find all elements within my DOM that begin with
"test". Any idea on how I would go about this?

Example Below I would like to return a list of element id's of test1,
test2, test3

<html>
<body>
<div id="spacer">
<div id="test1">Blah </div>
<div id="test2">Blah </div>
</div>
<div id="test3">Blah </div>
</body>
</html>
Use getElementsByTa gName('*'), loop through the elements, for those
with an ID, put the IDs (perhaps only the ones of interest) into an
array. Sort, slice, pop, whatever to your hearts content.

Keep an object handy with {id:elementRefe rnce,...} and use the array
as an index to get back to the elements - or just use getElementById.

Sounds like a bad idea, there must be another way to do whatever it is
you are trying to do.
--
Rob

Aug 15 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

44
3333
by: seberino | last post by:
Tuples are defined with regards to parentheses ()'s as everyone knows. This causes confusion for 1 item tuples since (5) can be interpreted as a tuple OR as the number 5 in a mathematical expression such as x = (5) * (4+6). Wouldn't it have been better to define tuples with <>'s or {}'s or something else to avoid this confusion?? Perhaps ()'s are a good idea for some other reason I don't know?
3
3557
by: Derek Fountain | last post by:
When is the use of <xsl:text>blah blah</xsl:text> necessary? I'm finding that, although it's used religously in the book I'm learning from, if I miss it out, the output is just the same.
4
9751
by: Carsten Kraft | last post by:
Hello Newsgroup, I think this is easy for you: I want to save the data line by line into an string array. eg. Text file: Array Line 1 Line1
2
2362
by: Hoss | last post by:
Hi guys, The framework of my page is an aspx page with a header and a footer. The header is a menu system and depending on what you select there different ascx pages are loaded into the middle part. So the entire page is encased in <form> tags. For this reason I cannot create <form> tags on a given ascx page. It screws things up. So, on one of my controls, I have the following -- set of 6 <input type=text id="myId">
2
1813
by: Paul Verbelen | last post by:
I have a file with topics. I like to copy them in another file but want to have some blank lines between the different topics. I use <xsl:text> element with as data some blank lines to perform this. To clarify my question, I have add all the files required to perform the test. First question: Why doesn't this works anymore if I remove the line with "&#x00A0;" in the XSL-file ?
11
3703
by: Ole Nielsby | last post by:
First, sorry if this is off-topic, not strictly being a C++ issue. I could not find a ng on numerics or serialization and I figure this ng is the closest I can get. Now the question: I want to serialize doubles in human-readable decimal form and be sure I get the exact same binary values when I read them back. (Right now, I don't care about NaN, infinities etc.)
14
3137
by: Michael | last post by:
Since the include function is called from within a PHP script, why does the included file have to identify itself as a PHP again by enclosing its code in <?php... <?> One would assume that the PHP interpreter works like any other, that is, it first expands all the include files, and then parses the resulting text. Can anyone help with an explanation? Thanks, M. McDonnell
5
3983
by: ajos | last post by:
hi frnds, this is the way i ve written--> <html:text name="bdgtmastForm" property="publicity_code" size="5" maxlength="5"> but its giving me an error which seems irrelevent.. type Exception report message
10
13367
by: test9991014 | last post by:
Hi all, I have an <input type=texttag that is taking up too much space vertically. It's in a <tdthat has a fixed height, and I've set the height value in the <input>'s style to be 10px, less than the <td>'s height which is set to 14 using a normal "height=14" parameter. For some reason the <inputis taking up the entire vertical space of the <td>, which I know because I set <td bgcolor=red>. I can see the input area which is about 10...
0
8337
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,...
0
8628
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...
1
6181
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5650
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
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2754
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
1978
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1739
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.