[英]Why doesn't my String/selector concatenation work?
Can anyone tell me why this doesn't work: 谁能告诉我为什么这行不通:
var cfHTML = '<div class="touch-feild" onclick="showPreview('+$(this).find('.feed-thumb')+')"></div>';
I get an "Uncaught SyntaxError: Unexpected identifier" 我收到“未捕获的SyntaxError:意外的标识符”
Hope someone can help me out here. 希望有人可以在这里帮助我。 I guess it must be a pretty simple question :-)
我想这肯定是一个非常简单的问题:-)
Thanks 谢谢
It think what you want to accomplish is onclick="showPreview($(this).find('.feed-thumb'))"
in your . 它认为您要完成的操作是您的中的
onclick="showPreview($(this).find('.feed-thumb'))"
。
var cfHTML = '<div class="touch-feild" onclick="showPreview($(this).find(\'.feed-thumb\'))"></div>';
$(this).find('.feed-thumb')
will give you jquery object not string. $(this).find('.feed-thumb')
将给你的jQuery对象不是字符串。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.