イベントを に設定しましたwrapper divが、この中divに がいくつかあります。このイベントが で発生するのを防ぐbuttonsにはどうすればよいですか?wrapperbuttons
html :
<div class="wrapper-alert"> <!-- click here will pop-up -->
<div class="somethingElse"> <!-- click here will pop-up -->
Some text
</div>
<div class="this-is-my-action">
<button class="inside-alert">Inside</button> <!-- click here will NOT pop-up-->
</div>
<div class="somethingElseTo"> <!-- click here will pop-up -->
Some text
</div>
</div>
より明確にするためにjsfiddleを作成しました。
したがって、基本的に、wrapper-alertメッセージをクリックするとポップアップが表示されますが、他のメッセージをクリックすると問題がbutton発生します。問題は、ボタンがラッパーの子であるため、2 つのイベントが同時に発生することです。
私は何かを試してみましたが、1つまたはいくつかの基本的な構造でif (e.target !== this) return;しか機能しません。children