197
rated 0 times
[
199]
[
2]
/ answers: 1 / hits: 67307
/ 13 Years ago, thu, october 13, 2011, 12:00:00
I'm building up a row to insert in a table using jQuery by creating a html string, i.e.
var row = ;
row += <tr>;
row += <td>Name</td>;
row += <td><input value='+data.name+'/></td>;
row += </tr>;
data.name
is a string returned from an ajax call which could contain any characters. If it contains a single quote, '
, it will break the HTML by defining the end of the attribute value.
How can I ensure that the string is rendered correctly in the browser?
More From » html