Javascript to hide selected option

前端 未结 4 1331
伪装坚强ぢ
伪装坚强ぢ 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:33

    As it's been said, you're trying to find an option within an option, so you'll have to get rid of the .find call.

    Apart from that, hiding elements do not work cross-browser, so you'll have to remove the options instead, and add them back when necessary. There are several ways to manage that, all involving storing the full list of options in a variable (as an array, an object, or even HTML string).

提交回复
热议问题