Test name | Executions per second |
---|---|
while | 141006.4 Ops/sec |
closest | 143635.7 Ops/sec |
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<style type="text/css">
.hidden {
display: none;
}
</style>
<div class="visible">
<div class="hidden">
<div class="hidden">
<div class="hidden hidden-last"></div>
</div>
</div>
</div>
<script>
Benchmark.prototype.setup = function() {
var $element = $('.hidden-last');
};
</script>
while ($element.is(":hidden")) {
$element = $element.parent();
}
$element = $element.closest(':visible')