0

ドロップダウンにカスタム jQuery を使用しました。現在、ドロップダウンのキーボード アップおよびダウン イベントの Mozilla を除くすべてのブラウザで正常に動作します。

ドロップダウン キーボード イベントに次のスクリプトを使用しました。

$(document).ready(function(){   
if (!$.browser.opera) {
    $('select.selectlistbig').each(function(){
        var title = $(this).attr('title');
        if( $('option:selected', this).val() != ''  ) title = $('option:selected',this).text();
        $(this)
            .css({'z-index':10,'opacity':0,'-khtml-appearance':'none'})
            .after('<span class="selectlistbig">' + title + '</span>')
            .change(function(){
                var val = $('option:selected',this).text();
                    $(this).next().text(val);
                })
    });

    $('select.selectlistbig').keypress(function (e) {
        if(e.keyCode == 37 || e.keyCode == 38 || e.keyCode == 39 || e.keyCode == 40 )
        {                   
            var val = $('option:selected', this).text();
            $(this).next().text(val);           
        }
    });
});

助けて。

ありがとうございました

4

1 に答える 1

0

e.keyCodeはFirefoxでは機能しません。plsはe.whichを使用して以下のコードを試してください:

$('select.selectlistbig').keypress(function (e) {
    var code = (e.keyCode ? e.keyCode : e.which);
    if(code == 37 || code == 38 || code == 39 || code == 40 )
    {                   
        var val = $('option:selected', this).text();
        $(this).next().text(val);           
    }

});
于 2013-01-31T09:46:34.257 に答える