Skip to main content

Quick and easy explanation of the jQuery command replace.

The replace() method returns a new string with some or all matches of a pattern replaced by a replacement. The pattern can be a string or a RegExp, and the replacement can be a string or a function to be called for each match.

Here’s an example of the syntax and how it works.

//Set the jQuery Variable
var ipAddress = '';

//Set text in document

//We want to remove the "/10" from the ipAddress variable
var ipAddressReplace = ipAddress.replace('/10','');

//Set text in document

You can view a demo of this here.

Leave a Reply