Home > Net >  Uncaught SyntaxError: missing ) after argument list while using onclick event
Uncaught SyntaxError: missing ) after argument list while using onclick event

Time:03-28

I am a beginner in JavaScript and I am facing a problem while using the onclick event Can you please help me?

movie1.innerHTML = `
                <img src="${IMG_URL   poster_path}" alt="Poster">
                <p >${title}</p>
                <span>Rating : ${vote_average}</span>
                <div >
                    <p>${overview}</p>
                </div>
              <button  onclick="passname(${title})" >Watch</button>
            </div>
        `;

In the Above code I get an error which shows "Uncaught SyntaxError: missing ) after argument list"

CodePudding user response:

Try this:

movie1.innerHTML = `
                <img src="${IMG_URL   poster_path}" alt="Poster">
                <p >${title}</p>
                <span>Rating : ${vote_average}</span>
                <div >
                    <p>${overview}</p>
                </div>
              <button  onclick="passname('${title}')" >Watch</button>
            </div>
        `;
  • Related