我正在努力实现以下目标:

$(".share-icon").html("<%= image_tag(@card.photo.url(:small)) %>");


这显然不起作用,但是如何在JS响应中使用image_tag

谢谢

最佳答案

尝试使用image_tag转义escape_javascript生成的html

$(".share-icon").html("<%= escape_javascript image_tag(@card.photo.url(:small)) %>");

09-07 20:08