Multiple select listbox without pressing CTRL

2020-04-07 18:55发布

问题:

I thought this would be easy to do but I can't find a way.

I have a ListBox with selection mode set to multiple but I the user wants to be able to select multiple items without having to press CTRL.

Does anyone know an easy way to do this?

回答1:

Googled it and find the following: http://www.erichynds.com/jquery/jquery-ui-multiselect-widget/

Here is some pointers:

  • Download and reference: https://raw.github.com/ehynds/jquery-ui-multiselect-widget/1.12/src/jquery.multiselect.js

The just type:

$(function(){
   $("select").multiselect(); 
});

Of course you need to reference jQuery as well, and the css to make it look good.

What the widget does is that it takes an select list and turn it create a list of checkboxes around it and styles them properly.

A simple jsfiddle example I put together: http://jsfiddle.net/AFVfQ/1/

It is not perfect, but it should show you how it works. Note the resources on the left hand side, the I'm referencing jquery ui css and a theme.



标签: asp.net