开发者

jQuery element property

is there a way to create/add multiple elements at once? In the following example I would like span an开发者_JS百科d ul to be both innerHTML properties of li:

jQuery('<li/>', {
  html: jQuery('<span/>', {
    text: 'a',
  }), jQuery('<ul/>', {
    text: 'b',
  })
}).appendTo("#t");

I would like to do it in one call, without having to pass a string of HTML (which I did before).

Thanks


You could do:

jQuery('<li/>')
   .append(jQuery('<span/>', {text: 'a'})
   .append(jQuery('<ul/>',  {text: 'b'})
   .appendTo("#t");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜