jQuery find checked checkbox

Benchmark created on


Preparation HTML

<ul class="nav nav-sidebar" id="nav-sidebar">
        <li>
            <div style="padding: 0 10px;">
                <div class="checkbox">
                    <label for="usePreset">
                        <input checked id="usePreset" type="checkbox">Use HTML5 Boilerplate preset
                    </label>
                </div>
            </div>
        </li>
        <li><strong><span class="caret"></span> Cross-Origin Resource Sharing</strong><div class="controls" id="cors"><div class="checkbox"><label for="cors-ajax"><input checked type="checkbox" id="cors-ajax">Cross-domain requests</label></div><div class="checkbox"><label for="cors-web-fonts"><input checked type="checkbox" id="cors-web-fonts">Cross-domain Web fonts</label></div><div class="checkbox"><label for="cors-images"><input checked type="checkbox" id="cors-images">CORS enabled images</label></div></div></li><li><strong><span class="caret"></span> Errors</strong><div class="controls" id="errors"><div class="checkbox"><label for="errors-multiviews"><input checked type="checkbox" id="errors-multiviews">404 error prevention</label></div><div class="checkbox"><label for="errors-pages"><input checked type="checkbox" id="errors-pages">Custom error messages / pages</label></div></div></li><li><strong><span class="caret"></span> Internet Explorer</strong><div class="controls" id="ie"><div class="checkbox"><label for="ie-experience"><input checked type="checkbox" id="ie-experience">Better website experience</label></div><div class="checkbox"><label for="ie-iframes"><input checked type="checkbox" id="ie-iframes">Cookie setting from iframes</label></div></div></li><li><strong><span class="caret"></span> Media Types and Charset</strong><div class="controls" id="media"><div class="checkbox"><label for="media-types"><input checked type="checkbox" id="media-types">Use the proper MIME types</label></div><div class="checkbox"><label for="media-charset"><input checked type="checkbox" id="media-charset">Use UTF8 charset</label></div></div></li><li><strong><span class="caret"></span> URL Rewrites</strong><div class="controls" id="rewrite"><div class="checkbox"><label for="rewrite-engine"><input checked type="checkbox" id="rewrite-engine">Turn on the rewrite engine</label></div><div class="btn-group" data-toggle="buttons"><label class="btn btn-primary" for="rewrite-www"><input checked type="radio" id="rewrite-www"> Force WWW</label><label class="btn btn-primary" for="rewrite-no-www"><input checked type="radio" id="rewrite-no-www"> Suppress WWW</label></div></div></li><li><strong><span class="caret"></span> Security</strong><div class="controls" id="security"><div class="checkbox"><label for="security-clickjacking"><input checked type="checkbox" id="security-clickjacking">Protect website against clickjacking</label></div><div class="checkbox"><label for="security-csp"><input checked type="checkbox" id="security-csp">Enable Content Security Policy</label></div><div class="checkbox"><label for="security-file-access"><input checked type="checkbox" id="security-file-access">Block access to private files</label></div><div class="checkbox"><label for="security-mime"><input checked type="checkbox" id="security-mime">Stop MIME-sniffing</label></div><div class="checkbox"><label for="security-xss"><input checked type="checkbox" id="security-xss">Protect website against XSS attacks</label></div><div class="checkbox"><label for="security-ssl"><input checked type="checkbox" id="security-ssl">Prevent SSL certificate warnings</label></div><div class="checkbox"><label for="security-hsts"><input checked type="checkbox" id="security-hsts">Force client-side SSL redirection</label></div><div class="checkbox"><label for="security-server"><input checked type="checkbox" id="security-server">Hide Server software information</label></div></div></li><li><strong><span class="caret"></span> Web Performance</strong><div class="controls" id="performance"><div class="checkbox"><label for="performance-compression"><input checked type="checkbox" id="performance-compression">Enable compression</label></div><div class="checkbox"><label for="performance-content"><input checked type="checkbox" id="performance-content">Disable content transformation</label></div><div class="checkbox"><label for="performance-etags"><input checked type="checkbox" id="performance-etags">Remove `ETags`</label></div><div class="checkbox"><label for="performance-expires"><input checked type="checkbox" id="performance-expires">Set expires headers</label></div><div class="checkbox"><label for="performance-cache-busting"><input checked type="checkbox" id="performance-cache-busting">Enable Filename-based cache busting</label></div><div class="checkbox"><label for="performance-file-concat"><input checked type="checkbox" id="performance-file-concat">Enable File concatenation</label></div></div></li>    </ul><script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

Test runner

Ready to run.

Testing in
TestOps/sec
$('.nav-sidebar input:checked')
var checked = $('.nav-sidebar input:checked')
ready
$('.nav-sidebar :checked')
var checked = $('.nav-sidebar :checked')
ready
$('.nav-sidebar').find('input:checked')
var checked = $('.nav-sidebar').find('input:checked')
ready
$('.nav-sidebar').find(':checked')
var checked = $('.nav-sidebar').find(':checked')
ready
$('#nav-sidebar input:checked')
var checked = $('#nav-sidebar input:checked')
ready
$('#nav-sidebar :checked')
var checked = $('#nav-sidebar :checked')
ready
$('#nav-sidebar').find('input:checked')
var checked = $('#nav-sidebar').find('input:checked')
ready
$('#nav-sidebar').find(':checked')
var checked = $('#nav-sidebar').find(':checked')
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.