Created
May 3, 2017 00:25
-
-
Save naveeninja/83482f1579945a0e2181bad8e7c40bff to your computer and use it in GitHub Desktop.
Demo jQuery Replace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Testing</title> | |
</head> | |
<body> | |
<h1><u>Demo jQuery Replace</u></h1> | |
Hello, this is a test replacing -9o0-9909 with <b>The new string</b>. | |
<br/><br/> | |
If I wrote -1o9-2202 and -1o9-2202 again but really wanted it to be <b>The ALL new string</b>. | |
<br/><br/> | |
This 12345-6789 wants to be <b>abcde-fghi</b>. | |
</body> | |
</html> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var replaced = $("body").html().replace('-9o0-9909','<b>The new string</b>'); | |
$("body").html(replaced); | |
var replaced = $("body").html().replace(/-1o9-2202/g,'<b>The ALL new string</b>'); | |
$("body").html(replaced); | |
$("body").html($("body").html().replace(/12345-6789/g,'<b>abcde-fghi</b>')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment