Jquery 选择器 特殊字符 转义字符
1、Jquery 选择器 id包含特殊字符,加双斜线 \\
例
<input type="text" id="dbo_HouseInfo.HouseResourceID" /> <script> var val= $("#dbo_HouseInfo\\.HouseResourceID").val(); </script>
2、HTML中的转义字符加单斜线 \
例
<!----html代码---> <input type="text" id="children" style="width: 50px;"oninput="value=value.replace(/[^\d]/g,'')"/><!----只允许数据数字的文本框--->
上述<input/>控件要动态添加时:
<script> var html = '<input type="text" id="children" style="width: 50px;"oninput="value=value.replace(/[^\\d]/g,\'\')"/>';//注意对比replace 内的代码与在HTML代码的差别 $("#father").prepend(html);//JQuery写法 //document.getElementById("father").innerHTML = html;//js写法 </script>
斩后知