html - javascript string replace special characters -


i have function removes filter html string if checkbox unchecked or adds if checked. having problems removing %20 or + symbol in front of string want remove using string replace function.

this code works:

var addfilter = change.value;  if (change.checked == true) { //add filter } else {     var removefilter1 = addfilter;     var removefilter2 = addfilter;          if(currfilter != '') {             var url = currfilter.replace(removefilter1, "");             var url = url.replace(removefilter2, "");             window.open(url, "_self");         }  } 

...basically tried setting removefilter1 = "%20" + addfilter; , removefilter2 = "+" + addfilter; rid of space characters in url doesn't when make change. i'm pretty sure has replace function not working special characters not sure how fix. isnt big of deal because still works spaces included bothering me lol.

%20 space, shown %20 in url denote space urls can't have space.. should try remove space not %20 string... e.g.

var url = currfilter.replace(" ", ""); 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -