Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can remove backslash in value by jQuery?

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

like image 604
Mehd S Avatar asked Jul 20 '11 07:07

Mehd S


2 Answers

$(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.

like image 92
Mark Keats Avatar answered Sep 23 '22 10:09

Mark Keats


var str = $(this).val().replace('/','');
like image 20
kleinohad Avatar answered Sep 25 '22 10:09

kleinohad