-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JavaScript > Event > Event Bubbling and Capturing > add
- Loading branch information
Showing
3 changed files
with
84 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
//** Event Bubbling | ||
const form = document.querySelector('form') | ||
const card_body = document.querySelector('.card-body') | ||
const card = document.querySelector('.card') | ||
const container = document.querySelector('.container') | ||
|
||
|
||
//** Icerden cole dogru olaylar tetiklenir => Event Bubbling | ||
// form.addEventListener('click',function(w){ | ||
// console.log('form') | ||
// w.stopPropagation()// just occur writeline action | ||
// }) | ||
|
||
// card_body.addEventListener('click',function(w){ | ||
// console.log('card body') | ||
// w.stopPropagation() | ||
// }) | ||
|
||
|
||
// card.addEventListener('click',function(w){ | ||
// console.log('card') | ||
// w.stopPropagation() | ||
// }) | ||
|
||
// container.addEventListener('click',function(w){ | ||
// console.log('container') | ||
// w.stopPropagation() | ||
// }) | ||
|
||
//** Event Capturing | ||
|
||
//** disdan iceri dogru olay => Event Capturing | ||
// form.addEventListener('click',function(w){ | ||
// console.log('form') | ||
// // w.stopPropagation()// just occur writeline action | ||
// },true) | ||
|
||
// card_body.addEventListener('click',function(w){ | ||
// console.log('card body') | ||
// // w.stopPropagation() | ||
// },true) | ||
|
||
|
||
// card.addEventListener('click',function(w){ | ||
// console.log('card') | ||
// // w.stopPropagation() | ||
// },true) | ||
|
||
// container.addEventListener('click',function(w){ | ||
// console.log('container') | ||
// // w.stopPropagation() | ||
// },true) | ||
|
||
const deleteElemnts = document.querySelectorAll('.fa-times') | ||
const deletall = document.querySelector('#btnDeleteAll') | ||
const ul = document.querySelector('ul') | ||
|
||
// deleteElemnt.forEach(function(item){ | ||
// item.addEventListener('click',function(w){ | ||
// // console.log(w.target.parentElement.parentElement) | ||
// w.target.parentElement.parentElement.remove() | ||
// w.preventDefault() | ||
|
||
// }) | ||
// }) | ||
|
||
ul.addEventListener('click',function(w){ | ||
if (w.target.className==="fas fa-times"){ | ||
w.target.parentElement.parentElement.remove(); | ||
w.preventDefault(); | ||
} | ||
}) | ||
|
||
|
||
deletall.addEventListener('click',function(w){ | ||
deleteElemnts.forEach(element => { | ||
element.parentElement.parentElement.remove() | ||
}); | ||
w.preventDefault() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,8 @@ | |
- Event | ||
- Event Listeners | ||
- Move Events | ||
- Keyboard Events | ||
- Event Bubbling and Capturing | ||
|
||
|
||
|
||
|