Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JavaScript Remove Text from the String</title> </head> <body> <script> // Sample string var str = "ID-123"; // Replacing text by empty string var newStr = str.replace("ID-", ""); document.write(newStr); // Prints: 123 </script> </body> </html>