<div id="home">
<div id="second"></div>
</div>
#home {
width: 100px;
height: 100px;
background-color: red;
}
#second {
width: 20px;
height: 20px;
background-color: green;
}
$(window).click(function(e) {
if(e.target.id == 'home'){
alert('This is div home!');
}
});
ここで緑のdivをクリックすると、これは機能しませんが、このdivはdivの赤です。 自動的にすべての子div idをホームに追加できますか?このdivに100人の子供がいる場合、100を追加する必要がありますか?機能の子供たちe?
'$( '#home').on( 'click'、function(){...});' –