there is a block and the event of a click on a block with id="event1" hangs 1 event js. when clicking on the block c id="close_event1" corresponding other event. But since the first block is the parent of the second, then we click only on 1 block in both versions. actually the question is how to do that to hang an event on a nested block, so as not to transfer it beyond the parent's limits, since when you click on the last, the parent must hide, and it is not very convenient

  <div class="main_block_participation"> <div class="event_border" id="event1"> <div class="event_image"> <img src="images/product/Без имени-1.jpg" /> <div class="event_note"> <div id="event_calendar_left">Left</div> <div id="event_calendar_count">#</div> <div id="event_calendar_days">Days</div> </div> </div> <div class="event_close" id="close_event1"> <img src="images/menu/bt_close_login_form.png" /> </div> <div class=""> <div class="event_date">19 December - 20 November</div> <div class="event_description"> text text text </div> </div> </div> </div> 
  • one
    event.stopPropagation(); - Deonis
  • it is not clear where exactly the method should be entered in the event by parent or by nested block - ddeadlink
  • all figured out, thank you) - ddeadlink

1 answer 1

To click on the child block did not trigger a click on the parent, you need to add a click event listener to this element and use the event.stopPropagation () event ascent function;

  • Thanks to you for the response, @Deonis has kindly suggested already) - ddeadlink