M-Amr Moussa M-Amr Moussa - 11 months ago 76
HTML Question

Appending Arabic Text in jquery

It gives me an error while executing this but when I replace the elements it works. What's wrong with those elements?

$("#formtobe").append( " <tr><td><input type="text" class="sub_input_box" id="plate_legnth" name="plate_length">
</td><td><p class= "input_label"> طـول البيلت</p></td>
<td><input type="number" class="sub_input_box" id="plate_count" name="plate_count"></td>
<td><p class= "input_label"> عـدد البيلتات </p></td></tr> ");

Answer Source

The issue in your code is not with the arabic text, but with the fact that you have unescaped quotes in the string.

At the moment, you have the string value " <tr><td><input type=", which is followed by the word text in a position where it is not syntactically valid. If you want text to be a part of the string, you need to escape the double quote that is currently being interpreted as the end of the string literal.

" <tr><td><input type=\"text\" ... "

If you are going to use double quotes in the string, but no single quotes, you may use single quotes to mark the start and end of the string, which saves you from some escapes:

' <tr><td><input type="text" ... '