jquery - JavaScript function parameter issue -
this question has answer here:
i'm using javascript function in html click , pass 3 parameters in
<div class="save_button" onclick="savetext('text','text_2000','plan share experiences week.')">submit</div>
this working fine function
function savetext(type,text_id,text_body){ // mycode }
note: 3rd parameter can text
when 3rd parameter came
<div class="save_button" onclick="savetext('text','text_2001','it's hot today, i'll do? (better not go outside!).let's have ice cream')">submit</div>
showing error in console
uncaught syntaxerror: missing ) after argument list
i know due additional (
, )
, '
coming on parameter. couldn't able remove 3rd parameter because dynamic
how can fixed.??
you're using quotes '
inside quote. breaking string , resulting in error.
escape quote preceding \
.
see highlighted changes in below code.
<div class="save_button" onclick="savetext('text','text_2001','it\'s hot today, i\'ll do? (better not go outside!).let\'s have ice cream')">submit</div> <!-- ^^ ^^ ^^ -->
Comments
Post a Comment