Skip to content

Commit

Permalink
JavaScript > Event > Event Bubbling and Capturing > add
Browse files Browse the repository at this point in the history
  • Loading branch information
DrMadWill committed Nov 11, 2021
1 parent 26b60f2 commit 9032556
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 1 deletion.
3 changes: 2 additions & 1 deletion 8_Events/Html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ <h5></h5>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<!-- <script src="../JavaScripts/19_8_1_EventListeners.js"></script> -->
<!-- <script src="../JavaScripts/20_8_2_Move_Event.js"></script> -->
<script src="../JavaScripts/21_8_3_Keyboard_Event.js"></script>
<!-- <script src="../JavaScripts/21_8_3_Keyboard_Event.js"></script> -->
<script src="../JavaScripts/21_8_4_Event_Bubnling.js"></script>

</body>

Expand Down
80 changes: 80 additions & 0 deletions 8_Events/JavaScripts/21_8_4_Event_Bubnling.js
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()
})
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
- Event
- Event Listeners
- Move Events
- Keyboard Events
- Event Bubbling and Capturing



Expand Down

0 comments on commit 9032556

Please sign in to comment.