开发者

jQuery - missing } after function body [closed]

开发者 https://www.devze.com 2023-01-17 11:26 出处:网络
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time,or an extraordinarily narrow situation that is not generally applic
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help m开发者_运维知识库aking this question more broadly applicable, visit the help center. Closed 10 years ago.

Where is problem: I got error: missing } after function body

(function($) { 
    $(document).ready( function() { 
        $("div.area_map").click( function () {
        alert('clicked'); 
        $('img.hoverswap', this).css({ 
            position:"absolute",
            left:"0px",
            top:"0px",
            width: "120",
            height: "52",
            zIndex: "9999"}).attr("src","default/citymap/D5.png");
            $.get("save.php", {id: 1, action: all}, function(result) {
                $("#results").html(result);
            }); 
        }); 
    }) ( jQuery ); 


is it just me or you have forgotten to close the ready handler function?

(function($) { 
    $(document).ready( function() { 
        $("div.area_map").click( function () {
        alert('clicked'); 
        $('img.hoverswap', this).css({ 
            position:"absolute",
            left:"0px",
            top:"0px",
            width: "120",
            height: "52",
            zIndex: "9999"}).attr("src","default/citymap/D5.png");
            $.get("save.php", {id: 1, action: all}, function(result) {
                $("#results").html(result);
            }); 
        });
    }); // <<--- missing here.
}) ( jQuery ); 


You forgot to close the

$("div.area_map").click( function () {

so add another });


try this:

  $(document).ready( function() {
    $("div.area_map").click( function () {
        alert('clicked');
     $('img.hoverswap', this).css({
        position:"absolute",
        left:"0px",
        top:"0px",
        width: "120",
        height: "52",
        zIndex: "9999"}).attr("src","default/citymap/D5.png");
        $.get("save.php", {id: 1, action: all}, function(result) {
            $("#results").html(result);
        });
    });

    });


Try this :)

$(document).ready(function() { 
    $("div.area_map").click( function () {
        alert('clicked'); 
        $('img.hoverswap', this).css({ 
            position  : "absolute",
            left      : "0px",
            top       : "0px",
            width     : "120",
            height    : "52",
            zIndex    : "9999"
        }).attr("src","default/citymap/D5.png");
        $.get("save.php", {id: 1, action: all}, function(result) {
            $("#results").html(result);
        });
    });
});
0

精彩评论

暂无评论...
验证码 换一张
取 消