Learn Basic String and Array Methods by Building a Music Player - Step 45

Tell us what’s happening:

hello can you help, im not sure where to use onclick method, from the step text i understood that it should be used on song title but it gives me an error , i also tried puting it at the end of the buitton but it also didnt work

Your code so far

<!-- file: index.html -->

/* file: styles.css */

/* file: script.js */
// User Editable Region

      <button class="playlist-song-info">
          <span class="playlist-song-title">${song.title}.onclick=playSong(${song.id})</span>
          <span class="playlist-song-artist">${song.artist}</span>
          <span class="playlist-song-duration">${song.duration}</span>
      </button>

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36

Challenge Information:

Learn Basic String and Array Methods by Building a Music Player - Step 45

Hi @markojovanovic985

The onclick needs to go in the button opening tag.

Happy coding

Hi thank you for trying to help but i still couldnt solve it also is my onclick syntax correct?, so i tried writting it right after first button word, after button class, right after opening tag and none of it worked :slight_smile:

please show your updated code

onclick is an attribute.

Write it like any other attribute.

If you are still having problems, please post your full code.

Happy coding

That solved it thank you so much i didnt realize this is inside HTML syntax and has to be written as an atribute thanks again

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.