tuupola / jquery_chained

Chained Selects for jQuery and Zepto
https://appelsiini.net/projects/chained/
589 stars 283 forks source link

Remove childs "Selected" attribute from <option> when parent is changed #65

Open hja0 opened 6 years ago

hja0 commented 6 years ago

If your using an "Selected" attribute on a child's option: <option selected> and change the parent and then change back the parent again the child will change to the option with the selected attribute. A little bit annoying.

This little fix will remove the "Selected" attribute from the child's

$(document).ready(function () {
    $("#mark").change(function () {
        $("#series option:selected").each(function () {
            $(this).removeAttr('selected');
        });
    })
});