Say I have 6 child divs and they don\'t have unique identifiers:
-
Wow, nice challenging question =)
while(($children = $(':not(.parent)>.child:lt(3)')).length) {
$children
.parent()
.append(
$('')
.append($children.remove())
);
}
Edit: Didn't know about the wrapAll
method, so:
while(($children = $(':not(.parent)>.child:lt(3)')).length) {
$children.wrapAll($(''));
}
- 热议问题