<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>https://jackxiang.com/index.php</link> 
<description><![CDATA[赢在IT，Playin' with IT,Focus on Killer Application,Marketing Meets Technology.]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></copyright>
<item>
<link>https://jackxiang.com/post//</link>
<title><![CDATA[html select美化模拟jquery插件select2.js]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[Php/Js/Shell/Go]]></category>
<pubDate>Tue, 01 Mar 2016 05:33:17 +0000</pubDate> 
<guid>https://jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	背景：像下拉这样的控件，有jQuery 插件autocomplete ，现在出来一个select2.js。<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp; select2.js是一个html select美化模拟类jquery插件，但是select2.js又远非简单的模拟美化那么简单，它还具有搜索功能，多选功能（可限制选择数量），ajax方式加载数据，可以设置placeholder，<br/>可以设置禁用状态disabled，并且设置非常简单，如：$(&quot;.js-example-disabled&quot;).prop(&quot;disabled&quot;, false);<br/><br/>select2.js默认值设置：$(&quot;#select2&quot;).val(&quot;1&quot;).trigger(&quot;change&quot;);&nbsp;&nbsp;多选的默认值可以使用$(&quot;#select2&quot;).val([&quot;1&quot;,&quot;2&quot;]).trigger(&quot;change&quot;);&nbsp;&nbsp;这样传递数组过去。<br/><br/>select2还有丰富的自定义事件<br/>$(&quot;#select2&quot;).on(&quot;select2:open&quot;, function (e) &#123; log(&quot;select2:open&quot;, e); &#125;);<br/>$(&quot;#select2&quot;).on(&quot;select2:close&quot;, function (e) &#123; log(&quot;select2:close&quot;, e); &#125;);<br/>$(&quot;#select2&quot;).on(&quot;select2:select&quot;, function (e) &#123; log(&quot;select2:select&quot;, e); &#125;);<br/>$(&quot;#select2&quot;).on(&quot;select2:unselect&quot;, function (e) &#123; log(&quot;select2:unselect&quot;, e); &#125;);<br/>$(&quot;#select2&quot;).on(&quot;change&quot;, function (e) &#123; log(&quot;change&quot;); &#125;);<br/><br/>更多丰富的select2用法请参考https://select2.github.io/examples.html，懒人建站也会在稍后给出实际应用中的一些例子，和一些方便调用的小花招。<br/><br/>select2小花招：自己定义当前选中的selected值，我们在select2的节点上给出一个&lt;select class=&quot;test1&quot; data-selected=&quot;2&quot;&gt; 看红色部分，然后我们就可以在设置选中值得时候就可以使用如下js代码，<br/>$(&quot;#select2&quot;).val(function()&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return $(this).data(&quot;selected&quot;)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;).trigger(&quot;change&quot;);<br/><br/>利用val()接收一个函数，而且可以利用 this<br/><br/>本文链接：html select美化模拟jquery插件select2.js<br/>http://www.51xuediannao.com/js/jquery/select2.html
]]>
</description>
</item><item>
<link>https://jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] html select美化模拟jquery插件select2.js]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>https://jackxiang.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>