select2使用


下载了select2的包,样式很好看,就自己在记事本里用着试试


<!DOCTYPE html>
<html>
  <head>
    <title>Bootstrap</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- Bootstrap -->
    <link href="./bootstrap.min.css" rel="stylesheet" media="screen">
	<script src="./jquery-2.0.3.min.js"></script>
	<script src="./jquery-migrate-1.2.1.js"></script>
        <script src="./bootstrap.min.js"></script>
	<link href="./select2.css" rel="stylesheet"/>
	<script src="./select2.min.js"></script>
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
    <![endif]-->
  </head>
  <body>
    <h1>Hello, world!</h1>
	<h1>Hello, world!</h1>
 <h2 class="page-header">区域一</h2>
 <p>Bootstrap has a few easy ways to quickly get started, each one appealing to a different skill level and use case. Read through to see what suits your particular needs.</p>
 <h2 class="page-header">区域二</h2>
 <p>If you work with Bootstrap's uncompiled source code, you need to compile the LESS files to produce usable CSS files. For compiling LESS files into CSS, we only officially support Recess, which is Twitter's CSS hinter based on less.js.</p>
 <h2 class="page-header">区域三</h2>
 <p>Within the download you'll find the following directories and files, logically grouping common resources and providing both compiled and minified variations.</p>
	
	<br>
	<button type="button" class="btn btn-default">Default</button>
        <button type="button" class="btn btn-primary">Primary</button>
        <button type="button" class="btn btn-success">Success</button>
        <button type="button" class="btn btn-info">Info</button>
        <button type="button" class="btn btn-warning">Warning</button>
        <button type="button" class="btn btn-danger">Danger</button>
        <button type="button" class="btn btn-link">链接</button>
<br>
<br>
<br>
	select2:
	<br>
        <select id="e1" style="width:300px">
	     <option ></option>
	     <optgroup label="一">
		  <option value="1">1</option>
		  <option value="2">2</option>
	     </optgroup> 
	     <optgroup  label="二">
		  <option value="3">3</option>
		  <option value="4">4</option>
	     </optgroup>
        <select>
 <script>
$(document).ready(function() { $("#e1").select2({
 placeholder: "Select a State",
 allowClear: true
}); });
</script>

  </body>
</html>

我导了jquery2.0.3的js。。。然后怎么都出不来效果。。

其实是版本的问题,用firebug查看了select2使用的jquery的js:

http://ivaynberg.github.io/select2/

发现select2用的是1.7.1版本的js。。。。

因此给自己的页面加一个js文件:jquery-migrate-1.2.1.js

就可以正常显示使用了~


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值