data-dojo-attach-point
发布时间:2020-12-16 21:21:09 所属栏目:百科 来源:网络整理
导读:在 Dojo declaration 和 Dojo template 中,经常见到 dojoAttachPoint="xxx"这种语句,经过查文档,终于有了些理性的认识。举例说明如下: 如果想在 js 中修改 thead 、tr 时,就可以通过 dojoAttachPoint 指定的别名 head,headRow 来引用到 thead,tr ,从而
在 Dojo declaration 和 Dojo template 中,经常见到 dojoAttachPoint="xxx"这种语句,经过查文档,终于有了些理性的认识。举例说明如下: 如果想在 js 中修改 thead 、tr 时,就可以通过 dojoAttachPoint 指定的别名 head,headRow 来引用到 thead,tr ,从而可以操作它。更深层地理解,就是 thead,tr 在页面的 DOM 树上分别对应着 DOM Node ,JS 操作 DOM 树时,要得到 DOM node 的实例时,才能对其进行操作。 比如在上面示例的表格中,要增加一个 td 结点时,就要得到 tr 的 instance,然后对其操作;在 JS 中实现的代码如下: var tth = document.createElement("th"); this.headRow.appendChild(tth); 或者: this.headRow.appendChild(document.createElement("td")); 其实和设置id,然后通过byId拿到dom节点也没有什么区别,只不过这样方面一点而已。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |