I have a div structure like this
-
For someone referring in future, a fixed and improved version of AdrianCooney 's answer:
$.fn.combine = function(selector) {
var parent = $(this[0]);
this.each(function(i) {
parent.append($(this).children(selector));
if(i>0)
$(this).remove();
});
};
You can call it like
$(".itemRow").combine('.item');
JSFiddle
- 热议问题