If you are finding out the easy way to replace character of a string, then use this replaceAll() jQuery inbuilt method. You may use the .replaceAll() method to find and replace all occurrences of a word inside any string. Let us show you the better example along with the syntax, how to find and replace a string with another in jQuery.



replaceAll() method has 2 required parameter, as mentioned above.

Example Code

Replace all <p> elements with <h3> elements


            $(document).ready(function() {

                $(“button”).click(function() {





Full Program

This program will show how the above function works. Let’s enter into the example and learn to try it out.

<!DOCTYPE html> 
		<title>The replaceAll Method</title> 
		<script src= 		"https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"> 
			$(document).ready(function() { 
				$("button").click(function() { 
			<button>Click to Replace</button> 

Leave a Reply

Your email address will not be published. Required fields are marked *