问题描述
为什么
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.
这篇关于undefined getElementById的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!