how can remove backslash in value by jQuery?

淺唱寂寞╮ 提交于 2019-12-21 08:26:08

问题


if $(this).val() have backslash remove backslash in it by jQuery. how is it? 1111\/11\/11 -> 1111/11/11


回答1:


$(this).val().replace(/\\/g, '');

You have to use two backslashes to get the \ character. A single backslash is used for control characters such as \r \n etc. Using the double backslash escapes this and gives you what you want.




回答2:


var str = $(this).val().replace('/','');



回答3:


Try this.

$(this).val($(this).val().replace(/\\/gi, ""));


来源:https://stackoverflow.com/questions/6758734/how-can-remove-backslash-in-value-by-jquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!