Difference between :checked and :selected when working with option elements in jQuery

Viewed 2248

Both :checked and :selected seem to provide equal results when working with <option> elements. Is there any advantage to using one over the other? If :selected does the same thing as :checked, what is the reason for it to be included in jQuery at all?

Example:

<p class="p1">Select a value</p>
<p class="p2">Select a value</p>

<select>
    <option value="a">Option one</option>
    <option value="b">Option two</option>
</select>


$('select').on('change', function(){

    $('.p1').text(function() { 
        return $('option:selected').text();
    });

    $('.p2').text(function() { 
        return $('option:checked').text();
    });
});

JS Bin demo

2 Answers
Related