I did find several questions concerning the NOT_FOUND_ERR: DOM Exception 8 error in combination with jQuery, but they did not happen in a scenario like mine and as such they did not provide a solution.
Basically, I have an object and I’m iterating over it and then adding rows to a <table> with id="legend": http://jsfiddle.net/nt9gZ/.
var items = [],
obj = {a: 1,
b: 2};
$.each(obj, function(i, v) {
items.push(
$("<tr>").append(
$("<td>").html(i),
$("<td>").html(v)
)
);
});
// .empty() is to erase contents when running this piece of code again
$("#legend").empty().append(
$(items)
);
When I run this piece of code, I get the error:
Uncaught Error: NOT_FOUND_ERR: DOM Exception 8
on Chrome.
I’m not sure what exactly is wrong with my code.
- What cannot be found?
- How can I solve this issue?
I’ve update your code a bit: http://jsfiddle.net/nt9gZ/8/
Basically there problem with the array –
appendmethod does not take array of jQuery objects as an argument, only a sequence of elements. So I’ve usedaddmethod to collect all rows together.