Replace string using jQuery

Category > JQUERY || Published on : Monday, June 22, 2015 || Views: 3577 || Replace string using jQuery Replace string Replace string using jQuery tutorial


In this tutorial we are going to learn to replace string using jquery so for this simple create a HTML page with the following codes.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $(".element span,p").text(function (index, text) {
                return text.replace('Hello', 'SourceCodehub');
            });
        });

    </script>
</head>
<body>
    <div class="element">
        <span>Hello</span>
        <p>
            Hello</p>
    </div>
</body>
</html>

so In this tutorial we have learn to replace string using jquery. Happy Coding!!!!