<style type="Text/css">Li { background: #eef; margin-bottom:5px; list-style-type: none; }. Color1{background: #ffe; margin-bottom:5px; list-style-type: none; }</style><script type="Text/javascript">$ (document). Ready ( function(){$("#selectable"). Selectable ({//Drag multiple selectionStop function(){ //When the drag selection ends, the stop event is triggered varresult=$ ("#select-result"). empty ();//Clear list of results$(". ui-selected", This). each ( function(){ //When selected, jQueryUI will automatically add style ui-selected, looping the result of the selection varindex=$ ("#selectable Li"). Index ( This);//Get the selected indexResult.append ("#"+ (index+1)+""+$( This). HTML ());//Display the selected index and value}) } }); $("Li"). Toggle ( function(){$( This). AddClass ("Color1"); }, function(){$( This). Removeclass ("Color1"); } );});</script></head><body> <p id="Feedback"> <span>The results that have been selected:</span><span id="Select-result">None</span> </P> <ol id="selectable"> <li class="Ui-widget-content">Zhangxiao</li> <li class="Ui-widget-content">John doe</li> <li class="Ui-widget-content">Wang Qiang</li> <li class="Ui-widget-content">Hanqi</li> <li class="Ui-widget-content">Lio Wangru</li> <li class="Ui-widget-content">Su Zhiyu</li> </ol></body>
jquery UI Selects multiple elements