Q:

missing ) after argument list error

I am writing the following code in a variable of JS to execute a function
"<p class='custom-popup-button-text' onclick='return goToNewsUrl("+news_url+");'>Detail News</p>"

Its returning following error

Uncaught SyntaxError: missing ) after argument list

What I am doing wrong?

A:

news_url must be wrapped by quotes:
'<p class="custom-popup-button-text" onclick="return goToNewsUrl(\'' + news_url + '\');">Detail News</p>'

