开发者

changes in jquery 1.4.2 breaking the code?

I had this code on a page using jquery 1.3, but now in jquery 1.4.2 it's breaking with syntax error/uncrecognized expression:

$(document).ready(function(){
    $("span[@name^=charge]").click(function(){
        $("#" + $(this).attr("name")).show();开发者_Go百科
        $(this).hide();
    });
});

How do I fix that?


@name has been deprecated - just use name now

See this thread: http://www.mail-archive.com/jquery-en@googlegroups.com/msg58250.html


the only thing I see is that I generally don't use the '@' before defining my property, and I tend to put my property value selector in single quotes. Try this:

$(document).ready(function(){
    $("span[name^='charge']").click(function(){
        $("#" + $(this).attr("name")).show();
        $(this).hide();
    });
});


Check the syntax of your selector - I think that's supposed to be

 span[name^='charge']
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜