This question already has an answer here:
I am echoing some data from the PHP side along with a tag and here is the code
echo '<a class="ui label" onclick="variant_desc('.$product_id.');"> '.$variant->Field1.' </a>';
Now the function that I have mentioned within the tag, when I click it throws me the
Uncaught SyntaxError: missing ) after argument list
error... BUT WHY? Where am I masking mistake?
</div>
I believe that it's caused of nested quotations. Try this instead:
echo '<a class=\"ui label\" onclick=\"variant_desc(\'.$product_id.\');\"> \'.$variant->Field1.\' </a>';