how can the children listen/capture to the parent's event

后端 未结 4 1919
Happy的楠姐
Happy的楠姐 2021-01-11 23:05

how can the parent fire the custom event to notify its children/siblings? for example:

4条回答
  •  余生分开走
    2021-01-11 23:25

    customEvent2 is only bound to div2. When you try to trigger it on div1, nothing happens because that event doesn't exist for div1.

    If you want to fire customEvent2, it has to be triggered on an element (or child of one) it is actually bound to.

提交回复
热议问题