Replacing Text in a child under parent DIV through JQuery-Collection of common programming errors

I want to change text of (Access denied. Please Login or Register.) to “You are not authorized to access” in the following code:-


Error message

Access denied. Please Login or Register.

I tried using the following code in on Ready Function, but it isn't working correctly.

$("div.messages").text(function () {
        console.log($(this).text());
        return $(this).text().replace("Access denied. Please Login or Register.", "You are not authorized to access"); 
    });

Thanks.

Is there anyother way to do that? It gives me the error of

Uncaught TypeError: Cannot set property 'nodeValue' of undefined ... 

Originally posted 2013-11-09 22:39:09.