Condition in source code is always false because selector :selected works only with <option> tags and doesn't work with generated <li selected="selected">.
if ($ul.find(":selected").length) {
...
} else {
...
}
It should be changed to $ul.find('li[selected]') or you should change attribute to data-selected and condition to $ul.find('li[data-selected]') which is much better esthetically, because selected="selected"should be used only for <option> tags.
Condition in source code is always false because selector
:selected
works only with<option>
tags and doesn't work with generated<li selected="selected">
.It should be changed to
$ul.find('li[selected]')
or you should change attribute todata-selected
and condition to$ul.find('li[data-selected]')
which is much better esthetically, becauseselected="selected"
should be used only for<option>
tags.