一个getElementById问题? [英] a getElementById question?

查看:81
本文介绍了一个getElementById问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


非常感谢您的帮助!


我如何使用诸如问题1之类的ID来引用多个元素br />
问题2,问题3等,如下所示?


document.getElementById(''question'')。innerHTML


我想使用


(var num = 1; num< 6; num ++){

document.getElementById(''question'')。 innerHTML

}


但是无法解决如何将问题1,问题2等纳入

代码...


谢谢


Geoff

解决方案

" Geoff Cox" ; < GE ******* @ notquitecorrectfreeuk.com>在消息中写道

新闻:nv ******************************** @ 4ax.com ...

您好,

在此感谢您的帮助!

如何使用诸如问题1之类的ID来引用多个元素问题2,问题3等,在下面?

document.getElementById(''question'')。innerHTML

我想用

for(var num = 1; num< 6; num ++){
document.getElementById(''question'')。innerHTML
}

但无法解决如何将问题1,问题2等纳入
代码......

Geoff




尝试


for(var num = 1; num< 6; num ++){

document.getElementById(''question''+ num).innerHTML

}


2005年10月11日星期二15:04:33 -0500,McKirahan < Ne ** @ McKirahan.com>

写道:

尝试

for(var num = 1; num< 6; num ++){
document.getElementById(''question''+ num).innerHTML
}




感谢您的回复 - 但是我曾经尝试过以上内容 - 我得到了


document.getElementById(..]为空或不是对象。


还有其他想法吗? !


干杯


杰夫



Geoff Cox在comp.lang.javascript上写了11 okt 2005

2005年10月11日星期二15:04:33 -0500,McKirahan ;< Ne ** @ McKirahan.com>
写道:

尝试

for(var num = 1; num< 6; num ++ ){
document.getElementById(''question''+ num).innerHTML
}
感谢您的回复 - 但我已经尝试了以上内容 - 我得到
document.getElementById(..]为null或不是对象。


你会忘记正确识别它们


< div id =''question1''...

< div id =''question2''...

< div id =''question3''...

< ; div id =''question4''...

< div id =''question5''...

还有其他想法吗?!




为什么?

-

Evertjan。

荷兰。

(用我的电子邮件地址替换所有带点的十字架)


Hello,

Would appreciate a little help here!

How do I refer to multiple elements with IDs such as question1,
question2, question3 etc, in following?

document.getElementById(''question'').innerHTML

I want to use

for (var num=1;num<6;num++) {
document.getElementById(''question'').innerHTML
}

but cannot work out how to get the question1, question2, etc into the
code...

Thanks

Geoff

解决方案

"Geoff Cox" <ge*******@notquitecorrectfreeuk.com> wrote in message
news:nv********************************@4ax.com...

Hello,

Would appreciate a little help here!

How do I refer to multiple elements with IDs such as question1,
question2, question3 etc, in following?

document.getElementById(''question'').innerHTML

I want to use

for (var num=1;num<6;num++) {
document.getElementById(''question'').innerHTML
}

but cannot work out how to get the question1, question2, etc into the
code...

Thanks

Geoff



Try

for (var num=1;num<6;num++) {
document.getElementById(''question''+num).innerHTML
}


On Tue, 11 Oct 2005 15:04:33 -0500, "McKirahan" <Ne**@McKirahan.com>
wrote:

Try

for (var num=1;num<6;num++) {
document.getElementById(''question''+num).innerHTML
}



Thanks for your reply - but I had tried the above - I get

document.getElementById(..] is null or not an object.

Any other thoughts?!

Cheers

Geoff



Geoff Cox wrote on 11 okt 2005 in comp.lang.javascript:

On Tue, 11 Oct 2005 15:04:33 -0500, "McKirahan" <Ne**@McKirahan.com>
wrote:

Try

for (var num=1;num<6;num++) {
document.getElementById(''question''+num).innerHTML
}
Thanks for your reply - but I had tried the above - I get

document.getElementById(..] is null or not an object.



You would, if you forget to id them correctly

<div id=''question1'' ...
<div id=''question2'' ...
<div id=''question3'' ...
<div id=''question4'' ...
<div id=''question5'' ...
Any other thoughts?!



why?
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)


这篇关于一个getElementById问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆