kagorastidis
11/17/2016 - 12:56 PM

this jquery extend function hides input options by wrapping them in a span with style: display:none; Works in IE 11

this jquery extend function hides input options by wrapping them in a span with style: display:none; 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