0

ID「exp_month」を使用した最初のコマンドのみが機能し、他の 2 つは機能しません。ID は現在 html に設定されています。

    if (month!="")
            $('select#exp_month>option:eq('+month+')').attr('selected', true);

    if (year!="")
            $('select#exp_year>option:eq('+year+')').attr('selected', true);

    if (state!="")  {
            $('select#x_state>option:eq("'+state+'")').attr('selected', true);
    }
4

1 に答える 1

0

問題は、「option:eq」が、オプション値ではなく、インデックス値によってオプションを選択することでした。

私は今使用しています:

$('#id").val(theVal)

于 2012-06-27T21:28:37.187 に答える