jQuery toggleClass example
Toggle class name on click in jQuery
by Slezi
HTML
<label id="buttonLabel">Test</label>
JavaScript
$("#buttonLabel").click( function() {
if($("input[id=buttonLabel]"))
$( "label" ).replaceWith( function() {
return "<input id="buttonLabel" type=\"text\" value=\"" + $( this ).html() + "\" />";
});
});
$("#View").click( function() {
$( "input[type=text]" ).replaceWith( function() {
return "<label>" + $( this ).val() + "</label>";
});
});