加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

dojo/dom-construct的create方法

发布时间:2020-12-16 21:34:41 所属栏目:百科 来源:网络整理
导读:create (tag,attrs,refNode,pos) Parameter Type Description tag DOMNode | String A string of the element to create (eg: "div","a","p","li","script","br"),or an existing DOM node to process. attrs Object An object-hash of attributes to set on

create(tag,attrs,refNode,pos)


Parameter Type Description
tag DOMNode | String

A string of the element to create (eg: "div","a","p","li","script","br"),or an existing DOM node to process.

attrs Object

An object-hash of attributes to set on the newly created node. Can be null,if you don't want to set any attributes/styles. See:dojo.setAttrfor a description of available attributes.

refNode
Optional.

Optional reference node. Used bydojo.placeto place the newly created node somewhere in the dom relative to refNode. Can be a DomNode reference or String ID of a node.

pos String
Optional.

Optional positional reference. Defaults to "last" by way ofdojo.place,though can be set to "first","after","before","last","replace" or "only" to further control the placement of the new node relative to the refNode. 'refNode' is required if a 'pos' is specified.yis

以上内容来自dojo1.9的API文档。

第四个参数pos的可选值有6个:first last before after replace only

前两个参数为必须的,后两个参数可选。


lz的唠叨:今天使用该method时总也得不到想要的结果,最后发现是因为页面和脚本中的id不一致。

现在想来这个问题是可以通过查看firebug中的dom解决的。其实往往犯得都是这样的小错误,以后检查时也要注意往这方面思考。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读