0

所以我不断收到错误“对象不支持此属性或方法”。我可以让菜单向下滑动,但是当我的鼠标离开菜单时我不能让它向上滑动。(#建议)

这是我的代码:(jQuery 1.6)

<script type="text/javascript">
function lookup(inputString) {
    if(inputString.length == 0) {
        // Hide the suggestion box.
        $('#suggestions').hide();
    } else {
        $.post("rpc.php", {queryString: ""+inputString+""}, function(data){
            if(data.length >0) {

                $('#suggestions').slideDown('slow');
                $('#autoSuggestionsList').html(data);

       // slideUp on mouseleave
        $('#suggestions').mouseleave(function() {
        $('#suggestions').slideUp('slow');
        });

            }

        });

    }

} // lookup


function fill(thisValue) {
    $('#inputString').val(thisValue);
    setTimeout("$('#suggestions').hide();", 200);
}

4

1 回答 1

1

Are you wrapping this code in a ready handler?

$(function(){
  // all your stuff in here so all the elements you select exist before you assign handlers to them
});

If not, you can get inconsistent results depending on where you put your script.

edit actually, this won't matter in your case because you're only defining functions here.

于 2011-06-18T19:28:07.480 回答