0

クラス名が「.ct」の20個のselectを含むページがあります。3つ以上のオプションを含むselectが存在するかどうかを判断するセレクターが必要です。

ありがとう、クリス

4

2 に答える 2

1

次のように、n番目の子セレクターを使用して3番目をチェックできます<option>

if ($('select.ct option:nth-child(3)').length)
    ; // Do stuff
于 2009-10-06T16:26:17.387 に答える
0
   var elem=$('select.ct');
    var exist=false;    
    $.each(elem,function(index,value){
    if(value.length>2)
    {
        exist=true;
        return
    }
    })
    if(exist)
        alert('select option with option greater than 3 exist')
    else
        alert('no select option exist greater than 3')
于 2012-04-27T10:20:10.597 に答える