当前位置:首页 > Web开发 > 正文

JS函数传递字符串参数(符号转义)

2024-03-31 Web开发

原文链接:https://blog.csdn.net/Myname_China/article/details/82907965

JS函数传递字符串参数,如果没有转义处理,在接收的时候无法正确的接收字符串。

在双引号内 <a href="javascript:orderDetails(\''+orderId+'\')">查看详情</a> <a href="javascript:void(0)" onclick="orderDetails(\''+orderId+'\')">查看详情</a> 在单引号内 <a href='javascript:orderDetails(\""+orderId+"\",\""+orderName+"\")'>查看详情</a> <a href='javascript:void(0)' onclick='orderDetails(\""+orderId+"\",\""+orderName+"\")'>查看详情</a>

如果参数为int类型,则不需要加引号和转义

JS函数传递字符串参数(符号转义)

温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/web/8605.html