I want to convert the code below into pure JavaScript
.
document.addEventListener('click', function(event) {
if (event.target.classList.contains('savedPlayer')) {
event.preventDefault();
let searchText = event.target.textContent.replace(" ", "%20");
console.log(searchText);
//resetState();
//renderPlayerBtns();
//searchBallDl(searchText);
//searchYouTube(searchText);
//searchGiphy(searchText);
}
});
div {
height: 20px;
border: 1px solid;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script>
<div class='savedPlayer'>savedPlayer 1</div>
<div class='savedPlayer'>savedPlayer 2</div>
<div class='other'>other</div>
I have some specific questions regarding the click event. Can a JS event listener have multiple arguments passed into it? What is the JS alternative to $(this)?
Appreciate the assistance!