jQuery val() Vs .children(:selected) (v2)

Revision 2 of this benchmark created on


Description

it was checking with the wrong selector :checked

Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<select>
<option value="a'>c</option>
<option value="b" selected=selected>b</option>
<option value="c">a</option>
</select>

Setup

var $select = $('select');

Test runner

Ready to run.

Testing in
TestOps/sec
val()
var val = $select.val();
ready
children(:selected)
var val = $select.children(':selected').val();
ready
filter(:selected)
var val = $select.find(':selected').val();
ready

Revisions

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