<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>http://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>http://jackxiang.com/post//</link>
<title><![CDATA[[实践Ok]html下拉单选变多选通过Jquery修改由单选变为多选的属性的方案。及jquery 如何修改a标签的内容，及根据值判断select控件是否disabled。]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[Php/Js/Shell/Go]]></category>
<pubDate>Mon, 23 Jul 2012 03:06:26 +0000</pubDate> 
<guid>http://jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	（一）<br/><textarea name="code" class="php" rows="15" cols="100">

&lt;select style=&quot;height:120px;width:260px;&quot; multiple=&quot;multiple&quot;&nbsp;&nbsp;id=&quot;sel-install-path&quot;&gt;
&lt;option value=&quot;-1&quot;&gt;请选择安装路径&lt;/option&gt;
&lt;option value=&quot;/tmp/projectOne&quot;&gt;/tmp/projectOne&lt;/option&gt;
&lt;option value=&quot;/tmp/projectTwo&quot;&gt;/tmp/projectTwo&lt;/option&gt;
&lt;option value=&quot;/tmp/jackxiangTest&quot;&gt;/tmp/jackxiangTest&lt;/option&gt;
&lt;option value=&quot;/data/adc&quot;&gt;/data/adc&lt;/option&gt;
&lt;/select&gt;
</textarea><br/>需要修改的属性：<br/> multiple=&quot;multiple&quot;&nbsp;&nbsp;height:auto;<br/>修改后如下：<br/> &lt;select style=&quot;height:auto;width:260px;&quot; id=&quot;sel-install-path&quot;&nbsp;&nbsp;multiple=&quot;multiple&quot; &gt;<br/><br/><br/>一：<br/>&lt;select name=&quot;select&quot; size=&quot;1&quot; multiple=&quot;multiple&quot; id=&quot;select&quot;&gt;<br/>我想给一个常规的select加上： multiple=&quot;multiple&quot; Jquery怎么加？<br/>二：<br/>那个height呢？<br/> &lt;select style=&quot;height:auto;width:260px;&quot; id=&quot;sel-install-path&quot;&nbsp;&nbsp;multiple=&quot;multiple&quot; &gt;<br/>开始是一个固定高度，我想修改为auto，怎么弄？<br/>&quot;height:auto;<br/> &lt;select style=&quot;height:auto;width:260px;&quot; id=&quot;sel-install-path&quot;&nbsp;&nbsp;multiple=&quot;multiple&quot; &gt;<br/><br/>方法:<br/><textarea name="code" class="php" rows="15" cols="100">
$(&quot;#sel-install-path&quot;).attr(&quot;multiple&quot;,&quot;multiple&quot;);
$(&quot;#sel-install-path&quot;).css(&quot;height&quot;,&quot;auto&quot;);
</textarea><br/><br/>如果想删除这个多选的属性：<br/><textarea name="code" class="php" rows="15" cols="100">
$(&quot;#sel-install-path&quot;).removeAttr(&quot;multiple&quot;,&quot;multiple&quot;);
</textarea><br/><br/>如何获取这个多选是不是真的多选？<br/><textarea name="code" class="php" rows="15" cols="100">
console.log($(&quot;#sel-install-path&quot;).attr(&quot;multiple&quot;)); //返回：true或者false
</textarea><br/>判断时的Js：<br/>multiple换成disabled：<br/><textarea name="code" class="JS" rows="15" cols="100">
if($(&quot;#sel-install-path&quot;).attr(&quot;disabled&quot;) === false)&#123;//是disabled而不是disable

&#125;
</textarea><br/>对这个多选的Js的Jquery的操作示例：<br/><textarea name="code" class="php" rows="15" cols="100">
//调试多选
var foo = [];
$(&#039;#sel-install-path :selected&#039;).each(function(i, selected)&#123;
foo[i] = $(selected).text();
&#125;);
console.log(foo);
</textarea><br/>返回：<br/>[ &quot;/tmp/projectOne&quot;, &quot;/tmp/projectTwo&quot;]<br/><br/>（二）jquery 如何修改&lt;a&gt;标签的内容<br/>&lt;a href=&quot;javascript:void(0);&quot; onClick=&quot;mutiPathBuShuChoose();&quot; id=&quot;mutiPathBuShuChooseHref&quot;&gt;多目标&lt;/a&gt;<br/>$(&quot;a#mutiPathBuShuChooseHref&quot;).html(&quot;单目标&quot;);<br/><br/><br/>整体示例：<br/><textarea name="code" class="php" rows="15" cols="100">
&nbsp;&nbsp;/*单个目标和多个目标的切换函数*/
&nbsp;&nbsp;function mutiPathBuShuChoose()
&nbsp;&nbsp;&#123;
&nbsp;&nbsp;&nbsp;&nbsp;if($(&quot;a#mutiPathBuShuChooseHref&quot;).html() == &quot;多目标&quot;)&#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(&quot;#sel-install-path&quot;).attr(&quot;multiple&quot;,&quot;multiple&quot;);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(&quot;#sel-install-path&quot;).css(&quot;height&quot;,&quot;auto&quot;);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var mutiPathBuShuChooseCautionContents = &quot;提示：请按住&lt;font color=red&gt;（Ctrl键+鼠标左键）&lt;/font&gt;进行多个目标地址的选取或取消。&quot;;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(&quot;#mutiPathBuShuChooseCaution&quot;).html(mutiPathBuShuChooseCautionContents);&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(&quot;a#mutiPathBuShuChooseHref&quot;).html(&quot;单目标&quot;);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.log($(&quot;#sel-install-path&quot;).attr(&quot;multiple&quot;));
&nbsp;&nbsp;&nbsp;&nbsp;&#125;else if($(&quot;a#mutiPathBuShuChooseHref&quot;).html() == &quot;单目标&quot;)&#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(&quot;#sel-install-path&quot;).removeAttr(&quot;multiple&quot;,&quot;multiple&quot;);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(&quot;#sel-install-path&quot;).css(&quot;height&quot;,&quot;20px&quot;);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var mutiPathBuShuChooseCautionContents = &quot;&quot;;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(&quot;#mutiPathBuShuChooseCaution&quot;).html(mutiPathBuShuChooseCautionContents);&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(&quot;a#mutiPathBuShuChooseHref&quot;).html(&quot;多目标&quot;);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.log($(&quot;#sel-install-path&quot;).attr(&quot;multiple&quot;));
&nbsp;&nbsp;&nbsp;&nbsp;&#125;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&#125;

</textarea>
]]>
</description>
</item><item>
<link>http://jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] [实践Ok]html下拉单选变多选通过Jquery修改由单选变为多选的属性的方案。及jquery 如何修改a标签的内容，及根据值判断select控件是否disabled。]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://jackxiang.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>