I have the following javascript:
var orderItemQuantity = $('<input/>', { type: 'hidden', name: 'order_detail[][quantity]', value: itemQuantity });
In the above javascript, the following error message appears:
Error: SyntaxError: DOM Exception 12
This works without errors:
var newListItem = $('<li/>', { html: $('#item_name_'+itemId).text() + '(' + $('#item_quantity_' + itemId).val() +')' + '<a onclick="removeItem(' + itemId + ')">Delete this</a>' + '<input type="hidden" name="order_detail[][item_id]" value="' + itemId + '"/>', id: itemId });
I checked the following question , but the answer did not clearly indicate the correct reason WHY.
Here is my DTD:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Question : why $('<input/>') and $('<input>') throw the specified exception, and $('<li/>') not a problem?
javascript jquery dom syntax-error dtd
nmenego
source share