I have a div which I use the jQuery functions to .hide()
or .show()
depending on the user inputs.
I've got a problem where the div in question doesn't get revealed when it should. The processing doesn't throw any errors but the div remains invisible. I've done a number of tests on the div and it seems that it should be visible!
The tests are shown below.
My question is what is a good way to 'walk' up from the div in question to the top of the DOM?
I want to do this in some diagnostics code so I can check visibility of each of the containing elements in case there's something there which is causing it to remain invisible. I really can't see why there should be but I'm running out of ideas.
EDIT 1 : The loop in the tests was just a double check that there was only element element with the ID of 'fanlist' . The output confirms this is the case but that's why the loop is there.
EDIT 2: I will have a look at the practicalities of exposing the HTML but I don't feel I can do this right now.
EDIT 3: Here is the output from the diagnostic code on an occassion when the div is not visibly rendered:
Here's the existing tests which are based on this question How do I check if an element is hidden in jQuery?.
fanlistVisDiagnostics: function () {
if ($('#fanlist').is(':visible')) {
console.log("C fanlist is visible")
} else {
console.log("C fanlist is not visible")
}
console.log("1DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD");
console.log("D fanlist offset.top = " + $("#fanlist").offset().top);
console.log("2DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD");
if( $("#fanlist").offset().top > 0 ){
console.log("D fanlist is visible")
}else{
console.log("D fanlist is not visible")
}
console.log("1EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE");
console.log($("#fanlist").css('display'));
console.log("2EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE");
if ( $("#fanlist").css('display') == 'none' ){
console.log("E fanlist is not visible")
}else{
console.log("E fanlist is visible")
}
console.log("*************************************************");
console.log("*ABout to iterate over the #fanlist return*******");
console.log("*************************************************");
$.each($("#fanlist"), function (id, varFanListFirstElement) {
console.log("*************************************************");
console.log("*Processing " + id + " *************************");
console.log("*************************************************");
console.log("1DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD");
console.log("D fanlist offset.top = " + $(varFanListFirstElement).offset().top);
console.log("2DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD");
console.log("1EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE");
console.log($(varFanListFirstElement).css('display'));
console.log("2EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE");
});
},