JSFiddle - React, Tailwind, and code Playground

by sirhc

HTML

Uncheck "Migrate 1.2.1" under Frameworks & Extensions on the left and click Run to see this work. Or switch between versions of jQuery. Note this is also broken on jQuery 1.7.2.

<option id="opt" selected="selected"></option>

<pre>.attr('selected'): <span id="selectedAttr"></span></pre>
<pre>.hasAttribute('selected'): <span id="hasAttribute"></span></pre>

JavaScript

var $opt = $('#opt')
           .prop('selected', false);

$('#selectedAttr').text(
    $opt.attr('selected')
);

$('#hasAttribute').text(
    $opt[0].hasAttribute('selected')
);