Home  >  Article  >  Web Front-end  >  Solution to JS string splicing error in IE_javascript skills

Solution to JS string splicing error in IE_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:54:161580browse

I haven’t used js for a long time, and I have forgotten a lot of stuff. Recently, I encountered a problem when splicing strings using JS. No matter how I spliced ​​it, an error was reported in IE, which was very frustrating.

A day later, I picked up the code and looked at it again. Suddenly I remembered the splicing of string escape characters in java, and then I remembered that js also has this stuff. " ";


No error is reported in the editor. No matter how to click onclick in the browser, it is not reflected. F12 reports an error. After reading the script, the string Completely transformed


The code is as follows:

tr = ""


is no problem.


Copy the code


The code is as follows:


onclick='confirmDelOneInfo("http://...?type=1&nodeId=11","Test 1");'


It can be seen that in html, if single quotes are used outside, they will be inside You must use double quotes, otherwise IE will report an error, so use the escape character " to convert double quotes. When dynamically generating HTML elements, pay special attention to the problem of single and double quotes, otherwise it will be a headache.
Haha , a summary of a little knowledge, corrections are welcome....
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn