jQuery UI Ticket #11199
HTML
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.min.css">
<input type="text" value="selected" />
<button type="button">Clear and Load Select</button>
JavaScript
jQuery(function () {
jQuery("input").focus();
jQuery("button").click(function () {
jQuery("body")
.html("");
alert(
"After HTML clear, window.getSelection().rangeCount = " + window.getSelection().rangeCount + ".\n" +
(
window.getSelection().rangeCount ?
"WTF?!?!?! There's nothing that can be selected!!!" :
"Hooray!!! As it should be!!!"
)
);
jQuery("body")
.append(
jQuery("<select>")
.attr("name", "test")
.append(
jQuery("<option>")
.val("1")
.text("Option 1")
)
.append(
jQuery("<option>")
.val("2")
.text("Option 2")
)
);
jQuery("select").selectmenu();
});
});