I have a class named validate[‘required’] and I need to put it inside
onclick="something();document.getElementById('something').setAttribute('class',here);"
the problem is that I get a syntax error : missing ) after argument list.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As per your comments I guess you are doing:
The string between
onclick="..."is parsed by the JavaScript interpreter of the browser.Of the JavaScript code, this fails:
because the JavaScript interpreter will think everything between
'and'will be your class name, so in your case:Then the interpreter also reads
required']'which it does not know how to handle, thus producing an error.To literally use the
'character without the browser using it as the end, you can escape it by prepending\: