How to use Checkbox inside Select Option

前端 未结 12 2309
夕颜
夕颜 2020-11-22 09:15

The client has given me a design which has a Select Option menu containing a checkbox together with the item name as individual items in the list. Is there anyway possible t

12条回答
  •  暖寄归人
    2020-11-22 09:39

    You can use this library on git for this purpose https://github.com/ehynds/jquery-ui-multiselect-widget

    for initiating the selectbox use this

        $("#selectBoxId").multiselect().multiselectfilter();
    

    and when you have the data ready in json (from ajax or any method), first parse the data & then assign the js array to it

        var js_arr = $.parseJSON(/*data from ajax*/);
        $("#selectBoxId").val(js_arr);
        $("#selectBoxId").multiselect("refresh");
    

提交回复
热议问题