[英]onclick javascript — > quotation marks
I have one onclick
like this line: 我有一个onclick
像这样的线:
onClick="function('value with special character 'like' quotation marks')"
How can I make it work? 我该如何运作?
The code broke when it "read" the quotation marks in the text ('like') 当“读取”文本中的引号时,代码破裂(“ like”)
Example: http://jsfiddle.net/Xs9Zd/ 示例: http : //jsfiddle.net/Xs9Zd/
Escape your quote marks: 转义引号:
onClick="function('value with special character \'like\' quotation marks')"
^ ^
That tells the JavaScript interpreter that those quotes are characters in the string, instead of an indication of the string's end. 这就告诉JavaScript解释器那些引号是字符串中的字符,而不是字符串结尾的指示。
尝试这个
onClick="function('value with special character "like" quotation marks')"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.