numArr = numArr.replace("\"","").replace("\"","")
如果不确定有多少个 双引号 :
numArr = numArr.replace(/\"/g, "")
去掉字符串中的双引号,参数中的字符串请用单引号
<script type="text/javascript">function dropComma(str) {
result = str.replace('"','')
alert(result)
}
dropComma('fjdklfjs"d')
</script>
工作中经常遇到字符串中含有"",由于js动态创建div元素,如果title中含有"",就会出现莫名的错误,由此记录下此bug。 var question = 是否经常感到"压力"或其他。 var newQuestion = question.replace(/\"/g, "-") //把 双引号用-代替 ,当然也可以""代替,表示去除。//检测某字符串中是否包含特殊字符 function special( str ){ var special = RegExp(/[(\ )(\~)(\!)(\@)(\#) (\$)(\%)(\^)(\&)(\*)(\()(\))(\-)(\_)(\+)(\=) (\[)(\])(\{)(\})(\|)(\\)(\)(\:)(\')(\")(\,)(\.)(\/) (\<)(\>)(\?)(\)]+/) return ( special.test(str) ) } 返回true说明有特殊符号。