<?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] Jquery一句话全选的代码及jquery 操作复选框checkbox的例子(全选,反选,获取选取值)]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[Php/Js/Shell/Go]]></category>
<pubDate>Tue, 25 Oct 2011 01:15:36 +0000</pubDate> 
<guid>http://jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	Jquery一句话全选的代码，实践Ok：$(&quot;input[type=&#039;checkbox&#039;]&quot;).attr(&quot;checked&quot;,&quot;checked&quot;);<br/><textarea name="code" class="JS" rows="15" cols="100">
&lt;!DOCTYPE Html&gt;
&nbsp;&nbsp; &lt;html&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&lt;head&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;script type=&quot;text/javascript&quot; src=&quot;http://code.jquery.com/jquery-1.4.4.min.js&quot;&gt;&lt;/script&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;script type=&quot;text/javascript&quot;&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function selectAll(checkbox) &#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(&#039;input[type=checkbox]&#039;).attr(&#039;checked&#039;, $(checkbox).attr(&#039;checked&#039;));
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/script&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&lt;/head&gt;
&nbsp;&nbsp; &lt;body&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;input type=&quot;checkbox&quot; onclick=&quot;selectAll(this);&quot; /&gt;全选&lt;br/&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;input type=&quot;checkbox&quot;&nbsp;&nbsp;/&gt;&lt;br/&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;input type=&quot;checkbox&quot;&nbsp;&nbsp;/&gt;&lt;br/&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;input type=&quot;checkbox&quot;&nbsp;&nbsp;/&gt;&lt;br/&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;input type=&quot;checkbox&quot;&nbsp;&nbsp;/&gt;&lt;br/&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;input type=&quot;checkbox&quot;&nbsp;&nbsp;/&gt;&lt;br/&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;input type=&quot;checkbox&quot;&nbsp;&nbsp;/&gt;&lt;br/&gt;
&nbsp;&nbsp; &lt;/body&gt;
 &lt;/html&gt;
</textarea><br/><br/><br/><textarea name="code" class="html" rows="15" cols="100">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;jquery 操作checkbox的例子(全选,反选,获取选取值)&lt;/title&gt;
&lt;script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;&gt;&lt;/script&gt;
&lt;script&gt;!window.jQuery &amp;&amp; document.write(&#039;&lt;script src=&quot;js/jquery-1.4.2.min.js&quot;&gt;&lt;&#92;/script&gt;&#039;)&nbsp;&nbsp;&nbsp;&nbsp;
&lt;/script&gt;
&lt;SCRIPT LANGUAGE=&quot;JavaScript&quot;&gt;
&nbsp;&nbsp;&nbsp;&nbsp; $().ready(function()&#123;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(&quot;#btn1&quot;).click(function()&#123;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $(&quot;[name=&#039;checkbox&#039;]&quot;).attr(&quot;checked&quot;,&#039;true&#039;);//全选

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(&quot;#btn2&quot;).click(function()&#123;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $(&quot;[name=&#039;checkbox&#039;]&quot;).removeAttr(&quot;checked&quot;);//取消全选

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(&quot;#btn3&quot;).click(function()&#123;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $(&quot;[name=&#039;checkbox&#039;]:even&quot;).attr(&quot;checked&quot;,&#039;true&#039;);//选中所有奇数

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(&quot;#btn4&quot;).click(function()&#123;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $(&quot;[name=&#039;checkbox&#039;]&quot;).each(function()&#123;


&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if($(this).attr(&quot;checked&quot;))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $(this).removeAttr(&quot;checked&quot;);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#125;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $(this).attr(&quot;checked&quot;,&#039;true&#039;);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#125;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#125;)

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $(&quot;#btn5&quot;).click(function()&#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var str=&quot;&quot;;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //$(&quot;[name=&#039;checkbox&#039;]&quot;).each(function()&#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(&quot;input[type=&#039;checkbox&#039;]:checked&quot;).each(function()&#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;str+=$(this).val()+&quot;&#92;r&#92;n&quot;;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#125;)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert(str);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;)
&nbsp;&nbsp;&nbsp;&nbsp; &#125;)
&lt;/SCRIPT&gt;
&lt;/HEAD&gt;

&lt;BODY&gt;
&lt;form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;&quot;&gt;
&nbsp;&nbsp;&lt;input type=&quot;button&quot; id=&quot;btn1&quot; value=&quot;全选&quot;&gt;
&nbsp;&nbsp;&lt;input type=&quot;button&quot; id=&quot;btn2&quot; value=&quot;取消全选&quot;&gt;
&nbsp;&nbsp;&lt;input type=&quot;button&quot; id=&quot;btn3&quot; value=&quot;选中所有奇数&quot;&gt;
&nbsp;&nbsp;&lt;input type=&quot;button&quot; id=&quot;btn4&quot; value=&quot;反选&quot;&gt;
&nbsp;&nbsp;&lt;input type=&quot;button&quot; id=&quot;btn5&quot; value=&quot;获得选中的所有值&quot;&gt;
&nbsp;&nbsp;&lt;br&gt;
&nbsp;&nbsp;&lt;input type=&quot;checkbox&quot; name=&quot;checkbox&quot; value=&quot;checkbox1&quot;&gt;
&nbsp;&nbsp;checkbox1
&nbsp;&nbsp;&lt;input type=&quot;checkbox&quot; name=&quot;checkbox&quot; value=&quot;checkbox2&quot;&gt;
&nbsp;&nbsp;checkbox2
&nbsp;&nbsp;&lt;input type=&quot;checkbox&quot; name=&quot;checkbox&quot; value=&quot;checkbox3&quot;&gt;
&nbsp;&nbsp;checkbox3
&nbsp;&nbsp;&lt;input type=&quot;checkbox&quot; name=&quot;checkbox&quot; value=&quot;checkbox4&quot;&gt;
&nbsp;&nbsp;checkbox4
&nbsp;&nbsp;&lt;input type=&quot;checkbox&quot; name=&quot;checkbox&quot; value=&quot;checkbox5&quot;&gt;
&nbsp;&nbsp;checkbox5
&nbsp;&nbsp;&lt;input type=&quot;checkbox&quot; name=&quot;checkbox&quot; value=&quot;checkbox6&quot;&gt;
&nbsp;&nbsp;checkbox6
&nbsp;&nbsp;&lt;input type=&quot;checkbox&quot; name=&quot;checkbox&quot; value=&quot;checkbox7&quot;&gt;
&nbsp;&nbsp;checkbox7
&nbsp;&nbsp;&lt;input type=&quot;checkbox&quot; name=&quot;checkbox&quot; value=&quot;checkbox8&quot;&gt;
&nbsp;&nbsp;checkbox8
&lt;/form&gt;
&lt;/BODY&gt;
&lt;/HTML&gt;

</textarea><br/><br/>选中所有的Checkbox：<br/><textarea name="code" class="html" rows="15" cols="100">
&nbsp;&nbsp;$(&quot;#check_all&quot;).click(function() &#123;
&nbsp;&nbsp;&nbsp;&nbsp;$(&quot;.check_item&quot;).attr(&quot;checked&quot;, this.checked);
&nbsp;&nbsp;&#125;);
</textarea><br/><br/><br/>  // 反选   $(&quot;#reverse-select&quot;).click(function() &#123;   $(&#039;.table tr&#039;).each(function() &#123;   var input = $(this).find(&#039;input&#039;);   var statu=input.prop(&quot;checked&quot;)==true?false:true;   input.prop(&quot;checked&quot;,statu);   &#125;);   &#125;);<br/>    我在table上面每一行放了个checkbox 然后用按钮单击，实现反选<br/>    <br/>    <br/>    主要是这一行：var statu=input.prop(&quot;checked&quot;)==true?false:true;<br/>    如果选中就为false否则为true<br/>    代码还可以精简的。<br/>    <br/>  作者：u010402518 发表于2013-5-5 1:51:15 原文链接   
]]>
</description>
</item><item>
<link>http://jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] [实践Ok] Jquery一句话全选的代码及jquery 操作复选框checkbox的例子(全选,反选,获取选取值)]]></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>