This is a simplified version of my problem.
I have two buttons, and one image. The image code is something like this
you can use jQuery wrap() function.
The code is:
$(function() {
//wrap
$('#button1').click(function() {
$('.onoff').wrap('');
//if you want to make sure multiple clicks won't add new around it
//you could unbind this event like that:
//$(this).unbind( "click" )
});
//unwrap
$('#button2').click(function() {
$('.onoff').parent().each(function() { $(this.childNodes).insertBefore(this); }).remove();
//$(this).unbind( "click" )
});
});