<ul id="filtration">
<li class="first">Urval</li>
<li>
<div class="selectContainer filtration">
<select id="filterType" class="filtration" multiple="multiple" size="1" autocomplete="off" style="visibility: hidden; ">
<option value="">Typ</option>
<option value="Klänningar">Klänningar</option>
<option value="Byxor" selected="selected">Byxor</option>
<option value="Toppar">Toppar</option>
</select>
<a class="dropdown ischanged"><span class="toggle"></span><span>Byxor</span></a><ul class="DD_values bullets" style="display: none; "><li><a href="#" data-val="Klänningar"><span>Klänningar</span></a></li><li><a href="#" data-val="Byxor" class="selected"><span>Byxor</span></a></li><li><a href="#" data-val="Toppar"><span>Toppar</span></a></li></ul></div>
</li>
<li>
<div class="selectContainer filtration">
<select id="filterColor" class="filtration" multiple="multiple" autocomplete="off" style="visibility: hidden; ">
<option value="">Färg</option>
<option value="red">Röd</option>
<option value="green">Grön</option>
<option value="blue">Blå</option>
</select>
<a class="dropdown"><span class="toggle"></span><span>Färg</span></a><ul class="DD_values bullets" style="display: none; "><li><a href="#" data-val="red"><span>Röd</span></a></li><li><a href="#" data-val="green"><span>Grön</span></a></li><li><a href="#" data-val="blue"><span>Blå</span></a></li></ul></div>
</li>
<li>
<div class="selectContainer filtration">
<select id="filterSize" class="filtration" autocomplete="off" style="visibility: hidden; ">
<option value="">Storlek</option>
<option value="XS">XS</option>
<option value="S">S</option>
<option value="M">M</option>
<option value="L">L</option>
<option value="XL">XL</option>
</select>
<a class="dropdown"><span class="toggle"></span><span>Storlek</span></a><ul class="DD_values bullets" style="display: none; "><li><a href="#" data-val="XS"><span>XS</span></a></li><li><a href="#" data-val="S"><span>S</span></a></li><li><a href="#" data-val="M"><span>M</span></a></li><li><a href="#" data-val="L"><span>L</span></a></li><li><a href="#" data-val="XL"><span>XL</span></a></li></ul></div>
</li>
<li class="sort">Sortering</li>
<li>
<div class="selectContainer filtration">
<select id="sortBy" class="filtration" autocomplete="off" style="visibility: hidden; ">
<option value="senast" selected="selected">Senast inkommet</option>
<option value="stigande">Stigande pris</option>
<option value="fallande">Fallande pris</option>
</select>
<a class="dropdown ischanged"><span class="toggle"></span><span>Senast inkommet</span></a><ul class="DD_values bullets" style="display: none; "><li><a href="#" data-val="senast" class="selected"><span>Senast inkommet</span></a></li><li><a href="#" data-val="stigande"><span>Stigande pris</span></a></li><li><a href="#" data-val="fallande"><span>Fallande pris</span></a></li></ul></div>
</li>
<li class="last"><a href="" class="clear_filt"><span>Visa</span></a>(50)</li>
</ul>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
var denna = $("#filterType"),
idn;
</script>
idn = denna.attr("id");
console.log($('select.filtration').not('#'+idn));
console.log(denna.parent().parent().siblings().find('select'));
console.log(denna.closest('li').siblings().find('select'));
console.log(denna.parents('li').siblings().find('select'));
console.log(denna.parent());
console.log(denna.closest('li'));
--enable-precise-memory-info
flag.
Test case name | Result |
---|---|
parent | |
parent().parent() | |
Closest | |
Parents(li) | |
Parent 2 | |
Closest 2 |
Test name | Executions per second |
---|---|
parent | 31936.2 Ops/sec |
parent().parent() | 36033.7 Ops/sec |
Closest | 31450.6 Ops/sec |
Parents(li) | 30110.2 Ops/sec |
Parent 2 | 55009.9 Ops/sec |
Closest 2 | 45501.2 Ops/sec |
I'll do my best to help.
It appears that this is a data dump from a benchmarking test, and I'm going to take a few educated guesses about what's being asked:
denna
object using various jQuery methods (e.g. .attr()
, .parent()
, .closest()
, etc.) to find a <select>
element.To provide a meaningful answer, I'll assume that the question is asking me to:
Based on the data, I notice that the test case "Parent 2" has a high execution count (55009.91015625) compared to the other test cases. This suggests that using .parent()
to find the parent element of denna
might be an efficient approach for this particular benchmarking scenario.
However, without more context about the specific use case or requirements of the code being tested, it's difficult to provide a definitive explanation for why "Parent 2" is performing better than the others. It's possible that other factors like caching, DOM manipulation order, or even the browser's JavaScript engine implementation are influencing the performance results.
To answer your question directly: The test case with the highest number of executions per second is "Parent 2", and I believe this might be due to the efficient use of .parent()
method in finding the parent element.