做英文的小说网站有哪些,商户网站建设公司,建设网站报价单,广告推广费用官方教程#xff1a;Dojo DOM Functions对dom的使用#xff0c;需要引用包dojo/dom。1.获取节点#xff0c;dom.byIdbyId中既可以传递一个字符串#xff0c;也可以传递一个节点对象 require([dojo/dom, dojo/domReady!], function(dom) {function …官方教程Dojo DOM Functions对dom的使用需要引用包dojo/dom。1.获取节点dom.byIdbyId中既可以传递一个字符串也可以传递一个节点对象 require([dojo/dom, dojo/domReady!], function(dom) { function setText(node, text){ node dom.byId(node);//通过已有对象 node.innerHTML text; } var one dom.byId(one);//通过字符串 setText(one, One has been set); setText(two, Two has been set as well); }); 2.创建节点domConstruct.create创建一个新的节点domConstruct需要引用包dojo/dom-construct包括4个参数。第一个节点名如lia第二个属性对象可以设置需要创建节点的各个属性、样式、内容和值第三个一个父节点或同级节点对象可选第四个一个插入点标志字符串由此决定是将第三个参数做为父节点附加到其内部或是做为同级节点插入可选默认为last表示附加到父节点最后first表示附加到父节点最前before表示插入到同级节点前after表示插入到同级节点后 require([dojo/dom, dojo/dom-construct, dojo/domReady!], function(dom, domConstruct) { var list dom.byId(list), three dom.byId(three); domConstruct.create(li, { innerHTML: Six }, list); domConstruct.create(li, { innerHTML: Seven, className: seven, style: { fontWeight: bold } }, list); domConstruct.create(li, { innerHTML: Three and a half }, three, after); }); 3.放置节点domConstruct.place改变已存在的一个节点的位置domConstruct.place包括三个参数。第一个目标节点是一个id字符串或节点对象即需要放置的节点第二个关联节点是一个id字符串或节点对象即目标节点将附加到该父节点最前或最后或者插入到该同级节点前或后第三个一个插入点标志字符串由此决定是将第二个参数做为父节点附加到其内部或是做为同级节点插入其前后可选默认为last表示附加到父节点最后first表示附加到父节点最前before表示插入到同级节点前after表示插入到同级节点后 require([dojo/dom, dojo/dom-construct, dojo/on, dojo/domReady!], function(dom, domConstruct, on){ function moveFirst(){ var list dom.byId(list), three dom.byId(three); domConstruct.place(three, list, first); } function moveBeforeTwo(){ var two dom.byId(two), three dom.byId(three); domConstruct.place(three, two, before); } function moveAfterFour(){ var four dom.byId(four), three dom.byId(three); domConstruct.place(three, four, after); } function moveLast(){ var list dom.byId(list), three dom.byId(three); domConstruct.place(three, list); } });4.毁灭节点domConstruct.destroy彻底删除一个已存在的节点及其子节点。如果仅需清空该节点下的子节点而保留该节点则用domConstruct.empty。参数都是一个id字符串或节点对象。 function destroyFirst(){ var list dom.byId(list), items list.getElementsByTagName(li); if(items.length){ domConstruct.destroy(items[0]);//删除list下第一个li子节点 } } function destroyAll(){ domConstruct.empty(list);//清空list下所有子节点 }