SO Help: How to use jQueryUI toggleClass
HTML
Original is RED.
<div id="myFragment" class="original">
<p id="f1">HERE NO ORIGINAL ITALICS</p>
<p id="f2">
<i>F</i>RAGMENT <big><i>with italics</i> and </big> withOUT.
</p>
<p id="f3"><i>HERE ORIGINAL ITALICS</i></p>
</div>
<button>Change</button>
CSS
.original {
background-color: red;
color: #000;
font-style:normal;
}
i.original { font-style:italic; }
.change {
background-color: #000;
color: #fff;
font-style:italic;
}
i.change{ font-style:normal; }
JavaScript
$("button").click(function(e) {
$('#myFragment *').each(function(){
$(this).toggleClass( "original change");
});
});
// ppkrauss