Sorry što se svađam sam sa sobom ali kod gore ima jednu grešku pa da ne bude kako širim dezionformacije
Naime, stari kod izvuče SVE podelemente i strpa ih u novi DIV ignorišući strukturu. U tom kodu će:
Kôd:
<p>Hello <b>there</b>.</p>
Biti transformisano u:
Kôd:
<p>Hello .</p>
<b>there</b>
No, evo ga fix. Mnogo je jednostavnije IMO:
Kôd:
jQuery.fn.collapsible = function() {
return this.each(function() {
var fieldset = jQuery(this);
var legend = fieldset.find(':first');
var body = jQuery(document.createElement('div'));
var children = fieldset.children();
var len = children.length;
if(len > 1) {
for(i = 1; i < len; i++) {
body.append(children[i]);
} // for
} // if
body.addClass('collapsibleFieldsetBody');
legend.addClass('collapsibleFieldsetTitle');
legend.after(body);
});
return this;
}