html - in jQuery, prevent deselecting all other options in a multiple select with "on" -


i have multiple select options added after page loads. want user able click option select/deselect clicking option, without having press control button, , without clearing selected options. have working select loaded in html, not select contains options added through jquery.

$(document).on("mousedown","#myselect option",function(){                     if ($(this).prop("selected"))   {          $(this).prop("selected",false);   }          else   {          $(this).prop("selected", true);   }  });     <select id="myselect" multiple="multiple">     <!-- these options added after page loads -->     <option id="id0" value="v0">t0</option>     <option id="id1" value="v1">t1</option>     <option id="id2" value="v2">t2</option> </select> 


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -