add id to dynamically created

后端 未结 6 2181
鱼传尺愫
鱼传尺愫 2020-12-23 18:48

I have the following JavaScript that creates a div and then appends it to the body and then inserts some dynamically generated HTML into it. cartDiv = document.createElement

6条回答
  •  南笙
    南笙 (楼主)
    2020-12-23 19:33

    You'll have to actually USE jQuery to build the div, if you want to write maintainable or usable code.

    //create a div
    var $newDiv = $('
    '); //set the id $newDiv.attr("id","myId");

提交回复
热议问题