简体   繁体   中英

onclick javascript — > quotation marks

I have one onclick like this line:

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')

Example: 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.

尝试这个

onClick="function('value with special character "like" quotation marks')"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM