views:

16

answers:

1

I want to pass jquery command into eval() function but I have found that some situation is not work.

For example, I have

$('input[name="lastName"]').val("xxx");

Then I pass into eval function

eval("$('input[name="lastName"]').val('xxx');");
eval('$('input[name="lastName"]').val('xxx');');

Because there are too many " or ' block in this pattern.
Seam it not make sense, how to solve this problem?

+1  A: 

Try:

eval('$("input[name=\'lastName\']").val("xxx")');
Darmen
It work, thank you
bugbug
you're welcome!
Darmen