entropia
10/4/2017 - 12:01 PM

Hide input Options

Works in IE 11

jQuery.fn.toggleOption = function( show ) {
    jQuery( this ).toggle( show );
    if( show ) {
        if( jQuery( this ).parent( 'span.toggleOption' ).length )
            jQuery( this ).unwrap( );
    } else {
        if( jQuery( this ).parent( 'span.toggleOption' ).length == 0 )
            jQuery( this ).wrap( '<span class="toggleOption" style="display: none;" />' );
    }
};

//usage 

jQuery('selector').toggleOption(true); // show the option
jQuery('selector').toggleOption(false); // hide the option