Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
JQuery: find with selected selector vs filter selected selector
find the best solution for optimize getting selected option
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36
Browser:
Chrome 130
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
with selected selector
308109.5 Ops/sec
with selected selector in filter
295143.4 Ops/sec
HTML Preparation code:
<select id="items"> <option value="1"></option> <option value="2"></option> <option value="3"></option> <option value="4"></option> <option value="5"></option> <option value="6"></option> <option value="7"></option> <option value="8"></option> <option value="9"></option> <option value="10"></option> </select> <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.js'></script>
Script Preparation code:
var $itemsElement = $("#items"); $itemsElement.val("5");
Tests:
with selected selector
$itemsElement.find("option:selected");
with selected selector in filter
$itemsElement.find("option").filter(":selected");