Luc*_*emy 1 javascript jquery replace
我有以下代码,正确实现了jQuery(它已经过测试才能运行):
var notrightfake = $("#ansbox").val();
var notright = notrightfake.replace(" ", "");
Run Code Online (Sandbox Code Playgroud)
并且$("#ansbox")是一个input type="text"盒子.但是说我输入He llo t his is m e,是不是应该显示的程序Hellothisisme,而不是根本不工作?
jsFiddle示例:http://jsfiddle.net/WUvu5/
感谢您的支持,
卢卡斯陈
该replace函数仅替换第一次出现的子字符串.
您必须使用正则表达式来替换所有出现的事件:
var notright = notrightfake.replace(/ /g, "");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
135 次 |
| 最近记录: |