Javascript to hide selected option

前端 未结 4 1377
伪装坚强ぢ
伪装坚强ぢ 2021-01-23 12:29

I have this code to hide selected options:

function connect()
{
    $(\".selectbox option\").show();
    $(\".selectbox\").each(function(i) { 
        var obj =          


        
4条回答
  •  醉酒成梦
    2021-01-23 13:27

    $('.selectboxes option:selected').find("option").hide();
    

    You are trying to find('option') inside option.. Try this

    $('.selectboxes option:selected').hide(); 
    

    You can also remove the element once and for all if you are using it again..

    $('.selectboxes option:selected').remove();
    

    To remove a option based on value you can try

    $('.selectboxes option[value="0"]').remove() ; // Removes option with value 0
    

提交回复
热议问题