Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用zepto创建的html对象不获取id_Javascript_Dom_Zepto - Fatal编程技术网

Javascript 使用zepto创建的html对象不获取id

Javascript 使用zepto创建的html对象不获取id,javascript,dom,zepto,Javascript,Dom,Zepto,当我使用zepto.js从HTML字符串创建元素时,如下所示: element = $("<ul />", {id:"myID"}); console.log(element); element.attr('id', 'myID'); 尽管最好不要像这样多做一步…但在版本Zepto.js(1.0rc1)中似乎没有引入此api 请参见中的第152行和第100-108行 和中的第167行和第110-128行 dom=zepto.fragment(selector.trim(),Reg

当我使用zepto.js从HTML字符串创建元素时,如下所示:

element = $("<ul />", {id:"myID"});
console.log(element);
element.attr('id', 'myID');

尽管最好不要像这样多做一步…

但在版本
Zepto.js(1.0rc1)
中似乎没有引入此api

请参见中的第152行和第100-108行

和中的第167行和第110-128行

dom=zepto.fragment(selector.trim(),RegExp.$1,context),selector=null
zepto.fragment=函数(html、名称、属性){
如果(html.replace)html=html.replace(tagExpanderRE,“”)
如果(name==未定义)name=fragmentRE.test(html)和&RegExp.$1
如果(!(容器中的名称))名称='*'
var节点,dom,container=containers[name]
container.innerHTML=''+html
dom=$.each(slice.call(container.childNodes),function(){
container.removeChild(此)
})
如果(isPlainObject(属性)){
节点=$(dom)
$.each(属性、函数(键、值){
if(methodAttributes.indexOf(key)>-1)节点[key](值)
else节点.attr(键,值)
})
}
返回dom
}
也读一下这个。也许它会在1.0的时候被引入

现在,在api开始工作之前,您可以使用以下代码完成此操作:

element = $("<ul />").attr({id:"myID"});
element=$(“
    ”).attr({id:“myID”});
似乎在版本
Zepto.js(1.0rc1)
中没有引入此api

请参见中的第152行和第100-108行

和中的第167行和第110-128行

dom=zepto.fragment(selector.trim(),RegExp.$1,context),selector=null
zepto.fragment=函数(html、名称、属性){
如果(html.replace)html=html.replace(tagExpanderRE,“”)
如果(name==未定义)name=fragmentRE.test(html)和&RegExp.$1
如果(!(容器中的名称))名称='*'
var节点,dom,container=containers[name]
container.innerHTML=''+html
dom=$.each(slice.call(container.childNodes),function(){
container.removeChild(此)
})
如果(isPlainObject(属性)){
节点=$(dom)
$.each(属性、函数(键、值){
if(methodAttributes.indexOf(key)>-1)节点[key](值)
else节点.attr(键,值)
})
}
返回dom
}
也读一下这个。也许它会在1.0的时候被引入

现在,在api开始工作之前,您可以使用以下代码完成此操作:

element = $("<ul />").attr({id:"myID"});
element=$(“
    ”).attr({id:“myID”});
dom = zepto.fragment(selector.trim(), RegExp.$1), selector = null

  zepto.fragment = function(html, name) {
    if (name === undefined) name = fragmentRE.test(html) && RegExp.$1
    if (!(name in containers)) name = '*'
    var container = containers[name]
    container.innerHTML = '' + html
    return $.each(slice.call(container.childNodes), function(){
      container.removeChild(this)
    })
  }
dom = zepto.fragment(selector.trim(), RegExp.$1, context), selector = null

  zepto.fragment = function(html, name, properties) {
    if (html.replace) html = html.replace(tagExpanderRE, "<$1></$2>")
    if (name === undefined) name = fragmentRE.test(html) && RegExp.$1
    if (!(name in containers)) name = '*'

    var nodes, dom, container = containers[name]
    container.innerHTML = '' + html
    dom = $.each(slice.call(container.childNodes), function(){
      container.removeChild(this)
    })
    if (isPlainObject(properties)) {
      nodes = $(dom)
      $.each(properties, function(key, value) {
        if (methodAttributes.indexOf(key) > -1) nodes[key](value)
        else nodes.attr(key, value)
      })
    }
    return dom
  }
element = $("<ul />").attr({id:"myID"});