select2 属性标签整理
前言:由于自己感覺自己學(xué)的越來越雜,很多東西使用之后就忘掉了很大一部分,所以最近決定把自己學(xué)的東西通過博客的方式整理出來,看能不能把這些知識(shí)都串通起來
?
SELECT2 標(biāo)簽
簡(jiǎn)單的關(guān)于以下API地址的翻譯
API地址 https://select2.github.io/examples.html
?
?
select2標(biāo)簽和傳統(tǒng)的select標(biāo)簽好像沒有多大的差別,但是它還是在select基礎(chǔ)上增加了些屬性
1、多個(gè)選擇框(屬性?multiple="multiple")
<select class="js-example-basic-multiple" multiple="multiple"> <option value="AL">Alabama</option> ... <option value="WY">Wyoming</option> </select>增加此屬性后,select選擇變成多選
2、選擇標(biāo)簽框?
你可以在一個(gè)標(biāo)簽中使用select標(biāo)簽,比如label
<label for="id_label_multiple">Click this to highlight the multiple select element<select class="js-example-basic-multiple js-states form-control" id="id_label_multiple" multiple="multiple"></select> </label>?
3、占位符 placeholder
這其實(shí)是h5的一個(gè)屬性,添加此屬性時(shí)在未選擇時(shí)選擇框中會(huì)出現(xiàn)placeholder所對(duì)應(yīng)的值
4、加載數(shù)組數(shù)據(jù)
簡(jiǎn)單的說:select2提供了一個(gè)加載局部數(shù)組的方法,你只要提供一個(gè)選項(xiàng)標(biāo)記,提供數(shù)組數(shù)據(jù)的初始選擇就可以了
?
Select2提供了一種方法,從
<script type="text/javascript"> var data = [{ id: 0, text: 'enhancement' }, { id: 1, text: 'bug' }, { id: 2, text: 'duplicate' }, { id: 3, text: 'invalid' }, { id: 4, text: 'wontfix' }]; $(".js-example-data-array").select2({ data: data }) $(".js-example-data-array-selected").select2({ data: data }) </script> <select class="js-example-data-array"></select> <select class="js-example-data-array-selected"> <option value="2" selected="selected">duplicate</option> </select>5、加載遠(yuǎn)程數(shù)據(jù)
6、
轉(zhuǎn)載于:https://www.cnblogs.com/nmqs-xuebi/p/6202605.html
總結(jié)
以上是生活随笔為你收集整理的select2 属性标签整理的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 数据库相关整理
- 下一篇: Cadence 电源完整性仿真实践(二)