Uncaught SyntaxError: missing ) after argument list while using onclick event
Uncaught SyntaxError: missing ) after argument list while using onclick event
我是 JavaScript 的初学者,在使用 onclick 事件时遇到问题
你能帮帮我吗?
movie1.innerHTML = `
<img src="${IMG_URL + poster_path}" alt="Poster">
<p class="title">${title}</p>
<span>Rating : ${vote_average}</span>
<div class="summary">
<p>${overview}</p>
</div>
<button class="watchbtn" onclick="passname(${title})" >Watch</button>
</div>
`;
在上面的代码中,我收到一个错误,显示“未捕获的语法错误:参数列表后缺少 )”
试试这个:
movie1.innerHTML = `
<img src="${IMG_URL + poster_path}" alt="Poster">
<p class="title">${title}</p>
<span>Rating : ${vote_average}</span>
<div class="summary">
<p>${overview}</p>
</div>
<button class="watchbtn" onclick="passname('${title}')" >Watch</button>
</div>
`;
我是 JavaScript 的初学者,在使用 onclick 事件时遇到问题 你能帮帮我吗?
movie1.innerHTML = `
<img src="${IMG_URL + poster_path}" alt="Poster">
<p class="title">${title}</p>
<span>Rating : ${vote_average}</span>
<div class="summary">
<p>${overview}</p>
</div>
<button class="watchbtn" onclick="passname(${title})" >Watch</button>
</div>
`;
在上面的代码中,我收到一个错误,显示“未捕获的语法错误:参数列表后缺少 )”
试试这个:
movie1.innerHTML = `
<img src="${IMG_URL + poster_path}" alt="Poster">
<p class="title">${title}</p>
<span>Rating : ${vote_average}</span>
<div class="summary">
<p>${overview}</p>
</div>
<button class="watchbtn" onclick="passname('${title}')" >Watch</button>
</div>
`;