Forum How do I...?

Iterating by elements using jquery

bulya
I want to wrap some part of content in:
<div class='page land'>...</div>

To show this content on a landscape page

I am using jquery to find element like this:
var need_to_split_tables = $("table.big_table");
console.log(need_to_split_tables.length);
need_to_split_tables.each(function(table){
    var colls = $(this).find("thead tr").find("td,th");
    console.log(colls.length)
    if (colls.length > 6) {
        $(this).wrap('<div class="page land" />')
    }
}

I can see in console correct need_to_split_tables.length
But colls.length is always "0"
At browser both values are correct. Please help, What I am doing wrong?
mikeday
Perhaps this is a bug in Prince, we shall need to investigate further. In the meantime, I think you can workaround the problem by rewriting the find call like this:
var colls = $(this).find("thead").find("tr").find("td,th");

Does this work for you?
mikeday
It seems that the issue is caused by Prince not supporting the Node.contains DOM function. We will add support for this function in a future release.
bulya
I solved this problem by adding additional classes to cells in table and just looking for this classes.
Thanks.
mikeday
For the record, we have added support for the Node.contains method in Prince 10, available now.