Jquery onclick on div

前端 未结 6 1460
被撕碎了的回忆
被撕碎了的回忆 2021-01-01 09:04

I have a simple question. The following code works for all the tags:

$(\'*\').click(function(e) {  
    alert(1);
});

But, when I try this

6条回答
  •  有刺的猬
    2021-01-01 09:24

    May the div with id="content" not be created when this event is attached? You can try live() jquery method.

    Else there may be multiple divs with the same id or you just spelled it wrong, it happens...

提交回复
热议问题