Prepend divs without closing them

前端 未结 1 1312
栀梦
栀梦 2020-12-04 03:23

I want to prepend the following within a div using Jquery:

相关标签:
1条回答
  • 2020-12-04 04:01

    You can't.

    Despite the abstraction it offers, jQuery doesn't operate on HTML, it operates on a DOM (where there are no start tags and no end tags, just elements).

    Build the DOM you want to prepend, and then prepend it.

    var $wrapper = $('<div class="section map-wrapper">');
    var $inner = $('<div class="wrapper section group inner-map-wrapper">')
    var $col = $('<div class="col span_12_of_12">');
    $inner.prepend($col);
    $wrapper.prepend($inner);
    $('.mpfy-tags-list').prepend($wrapper);
    
    0 讨论(0)
提交回复
热议问题