HTML コードにこの Select-Element があります。
<select id="pes_uni" name="pes_uni">
<option value="choose">Bitte auswählen</option>
<option value="7">HdM Stuttgart</option>
<option value="3">Hochschule Esslingen</option>
<option value="4">Hochschule Pforzheim</option>
<option value="1">Universität Bamberg</option>
<option value="5">Universität Bayreuth</option>
</select>
これらの Option-Tag の一部は、jQuerys.hide()
メソッドによって非表示になります。選択したばかりのオプションが非表示になる場合は、jQuery に表示されている次のオプションを選択してもらいます。したがって、私はこのコードを使用します:
if($("#pes_uni option:selected")
.is(":hidden")) $("#pes_uni option:selected")
.removeAttr('selected')
.next('option:visible')
.attr('selected', 'selected');
しかし、それは機能しません。何も起こりません。機能するのは、「next-parameter」なしでこのコードを使用することです。
$("option:selected").removeAttr('selected').next().attr('selected', 'selected');
しかし、ここでは次のオプションにジャンプしますが、これもおそらく目に見えないもので、私のターゲットではありません。
だから私の質問:なぜそれは動作しないのnext('option:visible')
ですか?これは間違ったjQuery-Syntaxですか?