dojo/dom-construct的create方法

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.setAttr for a description of available attributes.

refNode DOMNode | String
Optional.

Optional reference node. Used by dojo.place to 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 of dojo.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解决的。其实往往犯得都是这样的小错误,以后检查时也要注意往这方面思考。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值