How to create a DOM node as an object?

前端 未结 6 675
栀梦
栀梦 2020-12-07 20:04

I would like to create a DOM node, set the \'id\' attribute and then append it to \'body\'. The following seems not to work because jQuery doesn\'t see my template as an obj

6条回答
  •  醉梦人生
    2020-12-07 20:55

    var template = $( "
  • ", { id: "1234", html: $( "
    ", { class: "bar", text: "bla" } ) }); $('body').append(template);
  • What about this?

提交回复
热议问题