我知道这个问题有很多问题。但我想知道是否有任何替代方案可以解决这个问题。
问题:
我想获取数据库表中的现有文本,并将其放在HTML中的Textarea中。我正在使用Django框架。
$("textarea[name=profileitemdescription]").val("{{item.item_description}}");
如果\n
中没有换行符{{item.item_description}}
,则上述代码有效。
如果值({{item.item_description}}
)是单行,则将值放入Textarea。否则,它正在抛出Uncaught SyntaxError: Unexpected token ILLEGAL
。
在Textarea中放置值({{item.item_description}}
)的任何解决方法?