+ 1
[SOLVED]Why my code is not working?
https://sololearn.com/compiler-playground/WpcagVoCUwVO/?ref=app When i click on play button. I expect that icon get removed. But instead. It's showing error. The error arises because of line 53-57 of javascript. But I have no idea why!
11 Respuestas
+ 2
Manav Roy
do this instead:
Array.from(document.getElementsByClassName("songItemList")).forEach((e)=>{
e.addEventListener("click",function(){
// change to this:
e.classList.remove("far", "fa-play-circle");
});
});
+ 1
Event listener Incomplete...
Array.from(document.getElementsByClassName("songItemList")).forEach((e)=>{
e.addEventListener("click",function(){
e.target.classList.remove("far fa-play-circle");
// The logic to play the specific song is missing
+ 1
Music switching does not happen in the code
There are some variables that are not used yet in your project
+ 1
Zero I think it's the same code I've written 😅
+ 1
Yeah yeah, but it is incomplete and that is the error. Do you want me to send the correct code? I don't think that's right...
+ 1
Your code:
Array.from(document.getElementsByClassName("songItemList")).forEach((e)=>{
e.addEventListener("click",function(){
e.target.classList.remove("far fa-play-circle");
The fix:
Array.from(document.getElementsByClassName("songItemList")).forEach((e)=>{
e.addEventListener("click", function() {
// Toggles between play and pause for the clicked icon
this.classList.toggle("fa-play-circle");
this.classList.toggle("fa-pause-circle");
0
Zero
Music switching doesn't happen in my code cuz it's only 40% completed and I'm yet to add all the features...
I just want it remove the play icon when i click on it. But it's throwing error and idk why. What do u mean by "Event listener incomplete"?
0
Ah now what you want makes sense.
The code recognizes that the music player is incorrect so far.
0
About the Incomplete Event Listener, the music playback doesn't work... As an example, we only have the first player (because it only has one song in its code) and the music doesn't play... understand?
0
What I did above is just changing the icon, you can do the music player one! ;)
0
Zero Thank you so much !!