<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Power的部落格 &#187; Jquery</title>
	<atom:link href="http://www.forpower.com/blog/category/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.forpower.com/blog</link>
	<description>把夢越作越小了</description>
	<lastBuildDate>Wed, 15 Oct 2025 07:44:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.4</generator>
		<item>
		<title>jQuery 檢查元素是否存在</title>
		<link>http://www.forpower.com/blog/2018/05/30/jquery-%e6%aa%a2%e6%9f%a5%e5%85%83%e7%b4%a0%e6%98%af%e5%90%a6%e5%ad%98%e5%9c%a8/</link>
		<comments>http://www.forpower.com/blog/2018/05/30/jquery-%e6%aa%a2%e6%9f%a5%e5%85%83%e7%b4%a0%e6%98%af%e5%90%a6%e5%ad%98%e5%9c%a8/#comments</comments>
		<pubDate>Wed, 30 May 2018 03:26:09 +0000</pubDate>
		<dc:creator>power</dc:creator>
				<category><![CDATA[Jquery]]></category>

		<guid isPermaLink="false">http://www.forpower.com/blog/?p=659</guid>
		<description><![CDATA[if ($("#myDiv").length > 0) { alert(&#8216;Yes&#8217;); }else{ alert(&#8216;No&#8217;); }]]></description>
			<content:encoded><![CDATA[<p>if ($("#myDiv").length > 0)<br />
{<br />
alert(&#8216;Yes&#8217;);<br />
}else{<br />
alert(&#8216;No&#8217;);<br />
}</p>
]]></content:encoded>
			<wfw:commentRss>http://www.forpower.com/blog/2018/05/30/jquery-%e6%aa%a2%e6%9f%a5%e5%85%83%e7%b4%a0%e6%98%af%e5%90%a6%e5%ad%98%e5%9c%a8/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Jquery：textarea 多行 pleaceholder</title>
		<link>http://www.forpower.com/blog/2017/07/20/jquery%ef%bc%9atextarea-%e5%a4%9a%e8%a1%8c-pleaceholder/</link>
		<comments>http://www.forpower.com/blog/2017/07/20/jquery%ef%bc%9atextarea-%e5%a4%9a%e8%a1%8c-pleaceholder/#comments</comments>
		<pubDate>Thu, 20 Jul 2017 03:05:11 +0000</pubDate>
		<dc:creator>power</dc:creator>
				<category><![CDATA[Jquery]]></category>

		<guid isPermaLink="false">http://www.forpower.com/blog/?p=651</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<pre class="brush: jscript; title: ; notranslate">
var msg = &quot;TEST1\nTEST2\nTEST3&quot;;
$(&quot;#your_textarea&quot;).attr(&quot;placeholder&quot;, msg);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.forpower.com/blog/2017/07/20/jquery%ef%bc%9atextarea-%e5%a4%9a%e8%a1%8c-pleaceholder/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery：Set select option &#8216;selected&#8217;, by value</title>
		<link>http://www.forpower.com/blog/2017/07/11/jquery%ef%bc%9aset-select-option-selected-by-value/</link>
		<comments>http://www.forpower.com/blog/2017/07/11/jquery%ef%bc%9aset-select-option-selected-by-value/#comments</comments>
		<pubDate>Tue, 11 Jul 2017 03:20:47 +0000</pubDate>
		<dc:creator>power</dc:creator>
				<category><![CDATA[Jquery]]></category>

		<guid isPermaLink="false">http://www.forpower.com/blog/?p=629</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<pre class="brush: jscript; title: ; notranslate">
$(&quot;#myselect&quot;).val(&quot;value&quot;);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.forpower.com/blog/2017/07/11/jquery%ef%bc%9aset-select-option-selected-by-value/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery：Add options to a select from an array</title>
		<link>http://www.forpower.com/blog/2017/07/11/jquery%ef%bc%9aadd-options-to-a-select-from-an-array/</link>
		<comments>http://www.forpower.com/blog/2017/07/11/jquery%ef%bc%9aadd-options-to-a-select-from-an-array/#comments</comments>
		<pubDate>Tue, 11 Jul 2017 03:03:02 +0000</pubDate>
		<dc:creator>power</dc:creator>
				<category><![CDATA[Jquery]]></category>

		<guid isPermaLink="false">http://www.forpower.com/blog/?p=626</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<pre class="brush: jscript; title: ; notranslate">
$.each(selectArray, function(key, value) {
     $('#mySelect')
         .append($(&quot;&lt;option&gt;&lt;/option&gt;&quot;)
                    .attr(&quot;value&quot;,key)
                    .text(value));
});
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.forpower.com/blog/2017/07/11/jquery%ef%bc%9aadd-options-to-a-select-from-an-array/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery：checkbox 全選</title>
		<link>http://www.forpower.com/blog/2016/03/08/jquery%ef%bc%9acheckbox-%e5%85%a8%e9%81%b8/</link>
		<comments>http://www.forpower.com/blog/2016/03/08/jquery%ef%bc%9acheckbox-%e5%85%a8%e9%81%b8/#comments</comments>
		<pubDate>Tue, 08 Mar 2016 00:24:59 +0000</pubDate>
		<dc:creator>power</dc:creator>
				<category><![CDATA[Jquery]]></category>

		<guid isPermaLink="false">http://www.forpower.com/blog/?p=571</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<pre class="brush: xml; title: ; notranslate">
&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;checkbox 全選&lt;/title&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
$(document).ready(function(){
	$(&quot;#SelectAll&quot;).change(function(){
		  $(&quot;#form1 input[type='checkbox']&quot;).prop('checked', $(this).prop(&quot;checked&quot;));
	});
});
--&gt;
&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;input type=&quot;checkbox&quot; name=&quot;SelectAll&quot; id=&quot;SelectAll&quot; /&gt;全選
&lt;input type=&quot;checkbox&quot; name=&quot;checkbox[]&quot; id=&quot;checkbox&quot; value=&quot;1&quot; /&gt;
&lt;input type=&quot;checkbox&quot; name=&quot;checkbox[]&quot; id=&quot;checkbox&quot; value=&quot;2&quot; /&gt;
&lt;input type=&quot;checkbox&quot; name=&quot;checkbox[]&quot; id=&quot;checkbox&quot; value=&quot;3&quot; /&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.forpower.com/blog/2016/03/08/jquery%ef%bc%9acheckbox-%e5%85%a8%e9%81%b8/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jqGrid：Set Selected Rows</title>
		<link>http://www.forpower.com/blog/2015/12/04/jqgrid%ef%bc%9aset-selected-rows/</link>
		<comments>http://www.forpower.com/blog/2015/12/04/jqgrid%ef%bc%9aset-selected-rows/#comments</comments>
		<pubDate>Fri, 04 Dec 2015 02:59:03 +0000</pubDate>
		<dc:creator>power</dc:creator>
				<category><![CDATA[Jquery]]></category>

		<guid isPermaLink="false">http://www.forpower.com/blog/?p=425</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<pre class="brush: jscript; title: ; notranslate">
for (i = 0, count = rowArray.length; i &lt; count; i += 1) {
    $(&quot;#list&quot;).jqGrid('setSelection', rowArray[i], false);
}
</pre>
<pre class="brush: jscript; title: ; notranslate">
setTimeout(function(){ $(&quot;#list&quot;).jqGrid('setSelection', id); }
, 300);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.forpower.com/blog/2015/12/04/jqgrid%ef%bc%9aset-selected-rows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jqGrid：Single select checkbox</title>
		<link>http://www.forpower.com/blog/2015/12/04/jqgrid%ef%bc%9asingle-select-checkbox/</link>
		<comments>http://www.forpower.com/blog/2015/12/04/jqgrid%ef%bc%9asingle-select-checkbox/#comments</comments>
		<pubDate>Fri, 04 Dec 2015 02:51:35 +0000</pubDate>
		<dc:creator>power</dc:creator>
				<category><![CDATA[Jquery]]></category>

		<guid isPermaLink="false">http://www.forpower.com/blog/?p=422</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<pre class="brush: jscript; title: ; notranslate">
beforeSelectRow: function(rowid, e)
{
    jQuery(&quot;#list&quot;).jqGrid('resetSelection');
    return(true);
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.forpower.com/blog/2015/12/04/jqgrid%ef%bc%9asingle-select-checkbox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Jquery：Jeditable</title>
		<link>http://www.forpower.com/blog/2015/11/27/jquery%ef%bc%9ajeditable/</link>
		<comments>http://www.forpower.com/blog/2015/11/27/jquery%ef%bc%9ajeditable/#comments</comments>
		<pubDate>Fri, 27 Nov 2015 01:19:01 +0000</pubDate>
		<dc:creator>power</dc:creator>
				<category><![CDATA[Jquery]]></category>

		<guid isPermaLink="false">http://www.forpower.com/blog/?p=369</guid>
		<description><![CDATA[Save.php]]></description>
			<content:encoded><![CDATA[<pre class="brush: xml; title: ; notranslate">
&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;Jeditable&lt;/title&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
$(document).ready(function(){

    $(&quot;.edit&quot;).editable(&quot;Save.php&quot;,{
        indicator: &quot;Saving…&quot;,
        tooltip: &quot;Click to update&quot;,
        //event: &quot;click&quot;,
        //onblur: &quot;submit&quot;,
        type: &quot;text&quot;,
        width:($(&quot;span#edit&quot;).width() + 200) + &quot;px&quot;,
        height:($(&quot;span#edit&quot;).height() + 100) + &quot;px&quot;,
        style: &quot;display: inline&quot;,
        placeholder: &quot;Click to set text&quot;,
        cancel: &quot;取消修改&quot;,
        submit: &quot;確認修改&quot;,
        callback : function(value, settings) {
            //window.location.reload();
            var oTable = $(&quot;#myTable&quot;).dataTable();
            oTable.fnDraw();
        }
    });
});
&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;table id=&quot;myTable&quot;&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;span class=&quot;edit&quot; id=&quot;edit_1&quot;&gt;hello world!&lt;/span&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Save.php</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
$id = $_POST['id'];
$value = $_POST['value'];
list($field, $id) = explode('_', $id);
mysql_query(&quot;UPDATE tb_category SET $field='$value' WHERE cId='$id'&quot;);

//將值傳回前端
echo $value;
?&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.forpower.com/blog/2015/11/27/jquery%ef%bc%9ajeditable/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery UI：AutoComplete</title>
		<link>http://www.forpower.com/blog/2015/11/17/jquery-ui%ef%bc%9aautocomplete/</link>
		<comments>http://www.forpower.com/blog/2015/11/17/jquery-ui%ef%bc%9aautocomplete/#comments</comments>
		<pubDate>Tue, 17 Nov 2015 06:30:44 +0000</pubDate>
		<dc:creator>power</dc:creator>
				<category><![CDATA[Jquery]]></category>

		<guid isPermaLink="false">http://www.forpower.com/blog/?p=361</guid>
		<description><![CDATA[Search.php]]></description>
			<content:encoded><![CDATA[<pre class="brush: xml; title: ; notranslate">
&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;AutoComplete&lt;/title&gt;
&lt;script&gt;
$(function() {
	$(&quot;#tags&quot;).autocomplete({
		source: &quot;Search.php&quot;,
		minLength: 2,	//search after two characters
		select: function( event, ui ) {
                    console.log( ui.item ? &quot;Selected: &quot; + ui.item.value + &quot; aka &quot; + ui.item.id : &quot;Nothing selected, input was &quot; + this.value );
                }
	});
});
&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;label for=&quot;tags&quot;&gt;Tags：&lt;/label&gt;
&lt;input id=&quot;tags&quot;&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p><span style="color: #ff0000;"><strong>Search.php</strong><br />
</span></p>
<pre class="brush: php; title: ; notranslate">
$term = trim(strip_tags($_GET['term']));
$arr = array();

$sql = &quot;SELECT id,tag FROM test WHERE tag LIKE '&quot;.$term.&quot;%'&quot;;
$data = $this-&gt;db-&gt;getAll($sql);
foreach($data as $k =&gt; $v)	{
    $arr[$k]['id'] = $v['id'];
    $arr[$k]['value'] = $v['tag'];
}
echo json_encode($arr);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.forpower.com/blog/2015/11/17/jquery-ui%ef%bc%9aautocomplete/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jqGrid：Get custom jqGrid JSON data in loadComplete method</title>
		<link>http://www.forpower.com/blog/2015/11/04/get-custom-jqgrid-json-data-in-loadcomplete-method/</link>
		<comments>http://www.forpower.com/blog/2015/11/04/get-custom-jqgrid-json-data-in-loadcomplete-method/#comments</comments>
		<pubDate>Wed, 04 Nov 2015 08:03:43 +0000</pubDate>
		<dc:creator>power</dc:creator>
				<category><![CDATA[Jquery]]></category>

		<guid isPermaLink="false">http://www.forpower.com/blog/?p=321</guid>
		<description><![CDATA[jqGrid JSON response:]]></description>
			<content:encoded><![CDATA[<p><span style="color: #0000ff;">jqGrid JSON response:</span></p>
<pre class="brush: jscript; title: ; notranslate">
{
    //Custom JSON data:
    &quot;userdata&quot;:{&quot;lastSearchTime&quot;:&quot;2015/01/01:16:00:00&quot;},

    //Normal JSON data:
    &quot;page&quot;:1,
    &quot;records&quot;:101,
    &quot;rows&quot;:[...],
    &quot;rowCount&quot;:10,
    &quot;total&quot;:11
}

loadComplete: function() {
    var obj = $('#list').jqGrid('getGridParam', 'userData');
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.forpower.com/blog/2015/11/04/get-custom-jqgrid-json-data-in-loadcomplete-method/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
