473,468 Members | 1,713 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Is there a faster way to change span innerHTML

Here is the code I am currently using.... can anyone think of a speeder process?

-------
function changeDiv(tagID, tagData) {
if(document.getElementsByTagName) {
var divs = document.getElementsByTagName('span');
for(var i = 0, n = divs.length; i < n; ++i) {
if(tagID == divs[i].id) {
divs[i].innerHTML = tagData;
}
}
}
}
-------
Jul 23 '05 #1
2 20747


Charlie T wrote:
Here is the code I am currently using.... can anyone think of a speeder process?

-------
function changeDiv(tagID, tagData) {
if(document.getElementsByTagName) {
var divs = document.getElementsByTagName('span');
for(var i = 0, n = divs.length; i < n; ++i) {
if(tagID == divs[i].id) {
divs[i].innerHTML = tagData;


Well if you have unique id values (as you should have) you can just access
document.getElementById(tagID).innerHTML = tagData

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2
On Thu, 11 Nov 2004 18:57:58 +0100, Martin Honnen <ma*******@yahoo.de>
wrote:

[snip]
function changeDiv(tagID, tagData) {
if(document.getElementsByTagName) {
var divs = document.getElementsByTagName('span');
for(var i = 0, n = divs.length; i < n; ++i) {
if(tagID == divs[i].id) {
divs[i].innerHTML = tagData;


Well if you have unique id values (as you should have) you can just
access
document.getElementById(tagID).innerHTML = tagData


This is from a thread in September
(<URL:http://groups.google.com/groups?threadm=ee9445b6.0409071820.299b03d7%40post ing.google.com>).
The code above is based on my suggestion, but I was using classes, not ids.

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #3

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

Similar topics

1
by: mboso | last post by:
I have a function that works in firefox, but is having some issues in IE. What it does is place an image in a specified cell, when an icon in the adjacent cell is clicked. I have to click the link...
9
by: developer | last post by:
Does anyone know what is the way IE treats span tags(<span>) and table tags(<tr>, <td>)? Should the <span> tag be encolsed in tds and trs if it placed with other elements that are in a table? Can...
3
by: mscir | last post by:
I'm adding text to a div using innerHTML, and watching the width of the div using offsetWidth. In IE the offsetWidth increases when the div gets wider, but in Netscape 7.2 or Firefox 1.0.3 it...
1
by: developer | last post by:
Does anyone know what is the way IE treats span tags(<span>) and table tags(<tr>, <td>)? Should the <span> tag be encolsed in tds and trs if it placed with other elements that are in a table? Can...
4
by: bissatch | last post by:
Hi, I have the following simple HTML page. I am trying to get the innerHTML of the table element, "xmltable". I do intend to change the innerHTML of this table but at this stage I am having...
4
by: tcole6 | last post by:
My problem appears to be Firefox specific. I have a hyperlink that loads a new window. This window contains hyperlinks that call javascript functions in the parent window and then closes the...
7
by: John | last post by:
Hi Everyone, I'm having this extremely annoying problem with Internet Explorer 6, giving me an error message saying "unknown runtime error" whenever I try to alter the contents of a <divelement...
10
by: mjpdatadev | last post by:
I am relatively new to XMLRequest, DOM and Ajax but I really like the functionality. I have the DIV and SPAN changes working well but I thought that I would experiment with changing the actual...
15
by: rage3324 | last post by:
I am posting html onto my main page between div tags using xmlhttprequest and innerhtml. The html I am posting has javascript inside which I am executing using the eval() function. However, the...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
jinu1996
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...
1
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...
0
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,...
1
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...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.