开发者

Jquery problems with some chars in strings

I'm having troubles with some string chars like 'c++', when trying manipulating that i receive an error: uncaught exception: Syntax error, unrecognized expression: +

Is there some way of declaring strings or somenthing more that can be usefull to this case?

In this case i pass var k = 'c++' to a function which prints that var in this way:

$('#wrapper').html('<span>'开发者_C百科+k+'</span>');


Are you eval'ing the above code? As it stands what you have there works fine if it's just included in a page with var k = "c++".

If you are going to eval the string, then you should surround 'k' with quotes and also escape any quotes that might be in it.


That code looks fine. Runs with no problem here

That is not the line of code causing the error

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜