单引号和双引号

WBOY
Release: 2016-06-23 13:22:25
Original
1134 people have browsed it


怎么给All加个引号?

+"<div class='read' id='read2'><a href='javascript:;' onclick='getCategory2(All,"+pages+")' >READ MORE</a></div>"+
Copy after login


我试着用反斜杠给它加上引号但是没用
onclick='getCategory2("+"\'"+"All"+"\'"+","+pages+")'


回复讨论(解决方案)

onclick='getCategory2(\"All\","+pages+")'

+"

"+

var category="\"All\"";onclick='getCategory2("+category+","+pages+")' 这样可以了var category="\'All\'";  //改成单引号就不行了,Why?
Copy after login

 onclick='getCategory2(\"All\","+pages+")' 



+"

"+

为什么改成单引号就不行了呢?

因为你的分界符是双引,如果你使用单引,onclick=' 这里也是单引。
用单引包含单引会导致语法错误。

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!