undefined getElementById [英] undefined getElementById

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

问题描述

为什么

var offer = document.getElementById(" editor_displaying_t ext")。value;

返回undefined?

谢谢

Why
var offer=document.getElementById("editor_displaying_t ext").value;
returns undefined?
Thank You

推荐答案


为什么

var offer = document.getElementById(" editor_displaying_t ext") .value;

返回undefined?

谢谢
Why
var offer=document.getElementById("editor_displaying_t ext").value;
returns undefined?
Thank You



如果没有知识真的很难说什么是editor_displaying_text是。


我要继续说不是所有元素都有一个名为value的属性......事实上,大多数元素都没有。除非editor_displaying_text是OBJECT,PARAM,LI,INPUT是对象。或BUTTON,值将返回undefined。


阅读DTD:http://www.w3.org/TR/html/DTD/xhtml1-transitional.dtd,对值执行CTRL-F并且看看它经常出现的频率......不常见。


您可能想查看childNodes。数组中的元素中的dom元素列表 - 或者,如果您喜欢便宜的&简单的出路,innerHTML。

it''s really hard to tell without knowledge of what "editor_displaying_text" is.

I''m going to go on a limb and say not all elements have a property called "value"... in fact, most do not. Unless "editor_displaying_text" is an "OBJECT", "PARAM", "LI", "INPUT" or "BUTTON", value will return undefined.

Read the DTD: http://www.w3.org/TR/html/DTD/xhtml1-transitional.dtd, do a CTRL-F for "value" and see how often it shows up.... not very often.

You may want to check out the "childNodes" array for a list of dom elements within the element -- or, if you like the cheap & easy way out, innerHTML.


这是一个可编辑的div,id是editor_displaying_text

谢谢你
It''s an editable div which id is editor_displaying_text
Thank You


你''必须显示你的代码。你在哪里定义页面?
You''ll have to show your code. Where do you define it within the page?


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

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