-2

这是我的jQuery代码

    <script type="text/javascript" charset="utf-8">
 $(document).ready(function() {   
         $("#tasks").hide();
            $("select#categories").change(function(){
                    $("#tasks").show();
                    $.getJSON("ajax.php?module=responsibles&action=list_tasks",{id: $(this).val()}, function(j){

                            if($("#categories").val()=="-0") 
                            {                               
                                    $("#tasks").hide();
                            }
                            //if the div is hidden
                            $("div#form_objectifs").hide();
                            var options = '';
                            for (var i = 0; i < j.length; i++)
                            {
                                    options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>';
                            }
                            $("#tasks").html(options);
                            $('#tasks option:first').attr('selected', 'selected');
                    })
            })  

 });
</script>

此代码在 FF 或 Chrome 上运行良好,但在 IE 中无法用于向上、向下箭头键

任何人

4

1 回答 1

2

第一个问题:您的脚本中没有keyupkeydown事件。您使用change当您的元素失去焦点时触发的事件。

第二个问题:你使用$(document).ready(function() { ... });并且在这个你使用$(function(){ ... });。这是写同一件事的两种不同方式(第二种是第一种的别名)。选择其中之一,但不要同时选择两者。

第三个问题:请最好地解释您的问题,以便我们为您提供帮助;)。

于 2012-07-02T13:16:06.310 回答