How do you immunize the string when checking with td:contains?

How do you immunize the string when checking with td:contains?

I have a string like this

$("td:contains('" + ldName + "')").each(function () {
    //do something
}

But when ldName has a value like 'RestoreFactoryState();' it is thinking it as an executable statement (function call) and is trying to execute it. Is there a way we can make this to think it as a plain vanilla string and proceed.

I am getting a firefox error message like below

Timestamp: 8/3/2012 3:25:20 PM
Error: Error: Syntax error, unrecognized expression: td:contains('RestoreFactoryState();')
Line: 4272