Question: .replaceWith() for replacing both tags and texts

Question: .replaceWith() for replacing both tags and texts

I'd like ask why in the below example, "GOOGLE" is repeated three times, which is not intended.
What I just want to do is to remove the <a> tag thru jQuery.

  1. <script>
    $(function(){
        $('a').replaceWith( "<div>" + $(this).text() + "</div>" );
        });
    </script>

    <a href="#">GOOGLE</a>
    <a href="#">GOOGLE</a>
    <a href="#">GOOGLE</a>







And how about replacing the text "GOOGLE" with any other texts?
Is that something like this?

  1. <script>
    $(function(){
        $('a').replaceWith( "ANYTHING" );
        });
    </script>

    <a href="#">GOOGLE</a>
    <a href="#">GOOGLE</a>
    <a href="#">GOOGLE</a>









Thanks for any help!