Wrap multiple div elements on same class

前端 未结 5 938
执笔经年
执笔经年 2020-12-11 04:48

I would like to use jQuery to wrap sets of class elements in a div but can\'t find the solution.

HTML:

5条回答
  •  猫巷女王i
    2020-12-11 04:59

    Or here is the very short dynamical solution:

    ​$(".view-content > div").each(function() {
        $(".view-content > ." + this.className).wrapAll("
    "); });​

    DEMO: http://jsfiddle.net/CqzWy/

提交回复
热议问题