i have thousands of divs with hundreds of descendants inside, so i want to select one or more with removeeventlistener. Simply want to choose who listens to the event inside a div with descendant elements,for example:
I want to select that the input and the textarea cannot listen to the click event with removeeventlistener, but the div and the p tag do listen or that only the textarea listens and the others don't
<style>
.frame {
width: 300px;
height: 300px;
background-color: brown;
}
input {
margin: auto;
}
p {
font: bold 200% roboto;
text-align: center;
}
</style>
<body>
<div class="frame">
<input placeholder="">
<textarea></textarea>
<p>THIS IS P TAG</p>
div area
</div>
<div class="frame">
<input placeholder="">
<textarea></textarea>
<p>THIS IS P TAG</p>
div area
</div>
</body>
<script>
const labels = document.querySelectorAll('.frame');
for (var i = 0; i < labels.length; ++i) {
labels[i].addEventListener('click', function touch() {
// resize div
if( this.clientWidth == 300) {
this.style.width = "600px";
this.style.height = "600px";
}else{
this.style.width = "300px";
this.style.height = "300px";
};
//remove the event
this.firstElementChild.removeEventListener('click', touch);
//document.querySelectorAll('input').removeEventListener('click', touch);
});
};
</script>