Hi, just remove the this in your addEventListener part and change it to btn. And also one suggestion, if you just wanna toggle the status, add the attribute called playStatus to the root div, which is like container to those three divs and simply add and remove your divs to that attribute, instead of changing the status on every div.
Thanks for the feedback. i have tried changing this to btn and still doesn't work. What I mean is that I have 3 div elements and those elements have a <button class='play'> each. And whenever a button is clicked it should indicate on the parent element which is the div that the button is playing a audio. And when i click on the second button from div number two, the data-status='isPlaying' should be on the second div and not the first one anymore
Hi, just remove the
this
in youraddEventListener
part and change it tobtn
. And also one suggestion, if you just wanna toggle the status, add the attribute calledplayStatus
to the root div, which is like container to those three divs and simply add and remove your divs to that attribute, instead of changing the status on every div.Thanks for the feedback. i have tried changing
this
tobtn
and still doesn't work. What I mean is that I have 3div
elements and those elements have a<button class='play'>
each. And whenever a button is clicked it should indicate on the parent element which is thediv
that the button is playing a audio. And when i click on the secondbutton
fromdiv
number two, thedata-status='isPlaying'
should be on the seconddiv
and not the first one anymoreAlrighty, this is my markup,
And this is my script
Thank you so much...instead of using
button.parentNode.playStatus
i used it as a dataset so I can retrieve it later on...Thanks