开发者

Jquery Why is this var definition giving uncaught exception

Console.log is giving un开发者_如何学运维caught exception: Syntax error, unrecognized expression: #. This seems to be caused by $('#'+elmid+' div'). if i remove # then i do not get this error. What is causing this.

$(".abs").live('click',
function(e) {
    var elmid = $(this).attr('id');
    var editableid = $('#'+elmid+' div').attr('id');
    console.log(editableid);
});


My guess is that the clicked element does not actually have an id attribute. This means that your selector is # div, which is obviously an invalid jQuery selector. You should use find instead:

var editableid = $(this).find('div').attr('id');
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜