Replace text in a string with jQuery

<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Hello User!</title> <script type="text/javascript" src=""></script> <script type="text/javascript"> $(document).ready(function() { $(".element span").text(function(index, text) { return text.replace('British Pound', 'GBP'); }); }); </script> </head> <body> <div class="element"> <span>1 British Pound</span> </div> </body> </html>
Simple snippet showing string replace using jQuery

#stringReplace #replacement


Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.