I don't seem to have any problems selecting hidden elements.
$.each($("#ho3").prevAll(),function(idx,div) {
log($(div).attr("id"));
});
Domanda
Hi i have a hidden div which inside hold other divs
Example
<div style="display:none">
<div id="o-1">...<div>
<div>...<div>
<div>...<div>
<div id="o-2">...<div>
<div>...<div>
<div>...<div>
<div id="o-3">...<div>
<div>...<div>
<div>...<div>
</div>
I am trying to get the prevAll of div id="o-3" which id starts whith o- In the above example the prevAll of o-3 are o-2 and o-1
The problem is that because the wrapper div is hidden i can get the preAll
Any suggestions are welcome
Soluzione 2
I don't seem to have any problems selecting hidden elements.
$.each($("#ho3").prevAll(),function(idx,div) {
log($(div).attr("id"));
});
Altri suggerimenti
The problem is not that the parent is set to be hidden, the element is still in your DOM.
Instead, one problem is that your HTML is a bit messed up. You aren't closing your <div>
elements properly.
From your code:
<div>...<div>
Should be:
<div>...</div>
You could then use this to get the previous siblings that has an id that starts with o-
:
$("#o-3").prevAll("[id^='o-']")
Try with this
$('div:third').prevAll(':hidden');
or you can directly user
$("#o-3").prevAll("div[id^='o-']");