I have a javascript variable there is = some html i print out from a tabel in my server.
I use the variable in the Jquery function val(); but the problems is every time a person write some content in a field something with a " sign or a ' sign. the javascript get confused.
var message = '<%= raw(post.content) %>';
$("button").click(function() {
$("#somediv").val(message);
});
This code "<%= raw(post.content) %>" is a ruby on rails code there get the content from the content field in my post table.
Any suggestions what i can do?
"<%= j post.content %>" did solve the problem, like "vee" write in the comment.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.