why jquery each() not iterating?
I want to place a scroll indication on each tab which is built with Jquery
UI. As it happens the code below works for the first tab and stops there.
I tested and it goes just fine up till the if statement for all ul, but
only the first ul passes through the if statement, even if the second ul
at least also gives a true for that if
What am I missing?
Also I understand that each() will stop in case of false. How can I go
around that?
var i = 0;
$(".comp_pr ul").each(function () {
var element0 = $(this).attr('id');
var element1 = "#" + element0;
var element = document.querySelector(element1);
if ((element.offsetHeight < element.scrollHeight) ||
(element.offsetWidth < element.scrollWidth)) {
$(element1 + ' ' + "li:nth-child(4)
span:nth-child(3)").html('scroll <img id=""
src="img/forward.png" title=""/>');
$(element1 + ' ' + "li:nth-child(4)
span:nth-child(3)").attr('class', 'zscroll');
$(element1 + ' ' + "li:nth-child(4) span:nth-child(3)").attr('id',
'zs' + i);
}
i++;
});
A quick summary of the HTML:
<div class="comp_pr">
<ul id="measure0">
<li></li>
......
</ul>
</div>
<div class="comp_pr>
<ul id="measure1"
<li></li>
......
</ul></div>
....
No comments:
Post a Comment