Bootstrap select multiple choice drop-down box implementation code

 

Foreword

Projects to achieve multiple choice, think of using plug-in, choose the bootstrap-select.

Attach the official website link api, http://silviomoreto.github.io/bootstrap-select/ .

No Chinese. Deal and see. Have the opportunity to practice what each method will be summarized. I am also waiting.

They need to reference

 

?

1

2

3

4

5

6

7

8

<!-- Latest compiled and minified CSS -->

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.10.0/css/bootstrap-select.min.css">

 

<!-- Latest compiled and minified JavaScript -->

<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.10.0/js/bootstrap-select.min.js"></script>

 

<!-- (Optional) Latest compiled and minified JavaScript translation files -->

<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.10.0/js/i18n/defaults-*.min.js"></script>

Core Options

Some official website, looking forward translation. . .

The core method

Some official website, looking forward translation. . .

Examples of applications

After bootstrap layout, select multiple choice code is as follows

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

<div class="form-group">

    <label class="col-sm-3 control-label">客资类型:</label>

    <div class="col-sm-4">

    <select id="usertype" name="usertype" class="selectpicker show-tick form-control" multiple data-live-search="false">

     <option value="0">苹果</option>

     <option value="1">菠萝</option>

     <option value="2">香蕉</option>

     <option value="3">火龙果</option>

     <option value="4">梨子</option>

     <option value="5">草莓</option>

     <option value="6">哈密瓜</option>

     <option value="7">椰子</option>

     <option value="8">猕猴桃</option>

     <option value="9">桃子</option>

    </select>

    </div>

    </div>

js code:

?

1

2

3

4

5

$(window).on('load', function () {

 $('#usertype').selectpicker({

 'selectedText': 'cat'

 });

});

 

Get the value, $ ( "# XXX"). Val () to

Echo operation:

. Method $ ( '. Selectpicker') selectpicker ( 'val', 'Mustard'); 

Mustard place filled array. code show as below:

?

1

2

3

var str='3,4,5,6';

var arr=str.split(',');

$('#usertype').selectpicker('val', arr);

That's all for this article, I want to be helpful to learn, I hope you will support script home.

Guess you like

Origin www.cnblogs.com/zhuyeshen/p/11984396.html