$(document).on("hover","li.caption",function () {
            $(".cover", this).stop().animate({ top: '0px' }, { queue: false, duration: 160 });
        }, function () {
            $(".cover", this).stop().animate({ top: '-307px' }, { queue: false, duration: 160 });
        });

解决方案 »

  1.   

    hover 改成 mouseoverfunction getcityData(id, showul) {
            var sql = "id="+id;
            $.ajax({
                type: "get",
                dataType: "html",
                url: '/Ashx/act.ashx',
                data: sql,          
                success: function (data) {
                    $("#" + showul).html(data)
                },
                error: function (data) {
                    alert("页面提交失败,请重新提交.");
                    return false;
                }
            });
        }    $(document).ready(function () {
            getcityData(53, 'showjujiao');
            getcityData(54, 'showtese');
            getcityData(55, 'showlvyou');
        });    $(document).on("mouseover", "li.caption", function () {
            $(".cover", this).stop().animate({ top: '0px' }, { queue: false, duration: 160 });
        }, function () {
            $(".cover", this).stop().animate({ top: '-307px' }, { queue: false, duration: 160 });
        });=================
    谢谢回复,可这样的代码也执行不了。是哪里写错了?
      

  2.   


     $(document).on("mouseover", "li.caption", function () {
            $(".cover", this).stop().animate({ top: '0px' }, { queue: false, duration: 160 });
        });
     $(document).on("mouseleave", "li.caption", function () {
            $(".cover", this).stop().animate({ top: '-307px' }, { queue: false, duration: 160 });
        });
      

  3.   

    jquery 的ajax把
    <script scr='x'></script>封装好了。
    // Install script dataType
    jQuery.ajaxSetup({
    accepts: {
    script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
    },
    contents: {
    script: /(?:java|ecma)script/
    },
    converters: {
    "text script": function( text ) {
    jQuery.globalEval( text );
    return text;
    }
    }
    });// Handle cache's special case and global
    jQuery.ajaxPrefilter( "script", function( s ) {
    if ( s.cache === undefined ) {
    s.cache = false;
    }
    if ( s.crossDomain ) {
    s.type = "GET";
    s.global = false;
    }
    });// Bind script tag hack transport
    jQuery.ajaxTransport( "script", function(s) { // This transport only deals with cross domain requests
    if ( s.crossDomain ) { var script,
    head = document.head || jQuery("head")[0] || document.documentElement; return { send: function( _, callback ) { script = document.createElement("script"); script.async = true; if ( s.scriptCharset ) {
    script.charset = s.scriptCharset;
    } script.src = s.url; // Attach handlers for all browsers
    script.onload
     = script.onreadystatechange = function( _, isAbort ) { if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) { // Handle memory leak in IE
    script.onload = script.onreadystatechange = null; // Remove the script
    if ( script.parentNode ) {
    script.parentNode.removeChild( script );
    } // Dereference the script
    script = null; // Callback if not abort
    if ( !isAbort ) {
    callback( 200, "success" );
    }
    }
    }; // Circumvent IE6 bugs with base elements (#2709 and #4378) by prepending
    // Use native DOM manipulation to avoid our domManip AJAX trickery
    head.insertBefore( script, head.firstChild );
    }, abort: function() {
    if ( script ) {
    script.onload( undefined, true );
    }
    }
    };
    }
    });
    var oldCallbacks = [],
    rjsonp = /(=)\?(?=&|$)|\?\?/;// Default jsonp settings
    jQuery.ajaxSetup({
    jsonp: "callback",
    jsonpCallback: function() {
    var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( ajax_nonce++ ) );
    this[ callback ] = true;
    return callback;
    }
    });// Detect, normalize options and install callbacks for jsonp requests
    jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { var callbackName, overwritten, responseContainer,
    jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
    "url" :
    typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data"
    ); // Handle iff the expected data type is "jsonp" or we have a parameter to set
    if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) { // Get callback name, remembering preexisting value associated with it
    callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
    s.jsonpCallback() :
    s.jsonpCallback; // Insert callback into url or form data
    if ( jsonProp ) {
    s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
    } else if ( s.jsonp !== false ) {
    s.url += ( ajax_rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
    } // Use data converter to retrieve json after script execution
    s.converters["script json"] = function() {
    if ( !responseContainer ) {
    jQuery.error( callbackName + " was not called" );
    }
    return responseContainer[ 0 ];
    }; // force json dataType
    s.dataTypes[ 0 ] = "json"; // Install callback
    overwritten = window[ callbackName ];
    window[ callbackName ] = function() {
    responseContainer = arguments;
    };
    // Clean-up function (fires after converters)
    jqXHR.always(function() {
    // Restore preexisting value
    window[ callbackName ] = overwritten; // Save back as free
    if ( s[ callbackName ] ) {
    // make sure that re-using the options doesn't screw things around
    s.jsonpCallback = originalSettings.jsonpCallback; // save the callback name for future use
    oldCallbacks.push( callbackName );
    } // Call if it was a function and we have a response
    if ( responseContainer && jQuery.isFunction( overwritten ) ) {
    overwritten( responseContainer[ 0 ] );
    } responseContainer = overwritten = undefined;
    }); // Delegate to script
    return "script";
    }
    });
      

  4.   

    你可以试试这样
    $('li.caption').live("hover",function () {
                $(".cover", this).stop().animate({ top: '0px' }, { queue: false, duration: 160 });
            }, function () {
                $(".cover", this).stop().animate({ top: '-307px' }, { queue: false, duration: 160 });
    或者你设置你的
    $.ajax({
                type: "get",
                dataType: "html",
                url: '/Ashx/act.ashx',
                data: sql,
                async:flase,//设置为同步请求,让这段ajax 执行完毕再在执行别的操作
                 success: function (data) {
                    $("#" + showul).html(data)
                },
    });