Dojo问题:.parent()不是函数 [英] Dojo Issue: .parent() not a function
问题描述
HTML片段:
<div class="hide_on_start">
<label>Type of Visit</label>
<div id="record_visit_type"></div>
</div>
<div class="hide_on_start">
<label>Visit Date</label>
<div id="record_visit_date"></div>
</div>
<div class="hide_on_start">
<label>Staff</label>
<div id="record_staff"></div>
</div>
我使用的javascript:
The javascript I am using:
>>> dojo.byId('record_visit_type')
<div id="record_visit_type">
>>> dojo.byId('record_visit_type').parent().removeClass('hide_on_start')
TypeError: dojo.byId("record_visit_type").parent is not a function
我不明白问题是什么与 dojo.byId('record_visit_type')。parent()。removeClass(' hide_on_start')
。有人可以解释一下吗?
I don't understand what the issue is with dojo.byId('record_visit_type').parent().removeClass('hide_on_start')
. Can somebody explain?
谢谢
推荐答案
我看到你的代码:
我想你正在寻找的是你的domNode的 parentNode
属性检索。这不是一种方法,而是通过 dojo.byId
查找的domNode的属性。
I think what you are looking for is the parentNode
property of the domNode you are retrieving. This is not a method, but a property of the domNode you are looking up via dojo.byId
.
另外,domNodes本身没有一个removeClass方法。您可能想要使用dojo的 dojo.removeClass(domNOde,cssClass)
方法来执行此操作。
Also, domNodes themselves to not have a removeClass method. You probably want to use dojo's dojo.removeClass(domNOde, cssClass)
method to do this.
var recordVisitTypeDomNode = dojo.byId('record_visit_type');
dojo.removeClass(recordVisitTypeDomNode.parentNode, 'hide_on_start');
这篇关于Dojo问题:.parent()不是函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!