I have an array on javascript and i insert the elements on it like this:
var parentRow = $(button).parent().parent();
list.push({ parent: parentRow, detailRow: newRow });
On the click of another button i do the following:
var parentRow = $(button).parent().parent();
var detailRow = null;
for (var i in list) {
if ($(list[i].parent) == $(parentRow)) {
detailRow = list[i].detailRow;
}
}
The point is: The if comparing to two elements should return TRUE, because they are the same DOM element….the same i added before, but it return FALSE.
I would like to know how i compare this two elements to get TRUE there.
You need to compare the native elements, not the jQuery-wrapped elements. jQuery’s DOM methods returns not the elements themselves but a jQuery object.