{"id":243,"date":"2014-02-15T15:01:46","date_gmt":"2014-02-15T06:01:46","guid":{"rendered":"http:\/\/lovelinux.mydns.jp\/?p=243"},"modified":"2014-04-01T13:22:55","modified_gmt":"2014-04-01T04:22:55","slug":"jquery-plugin%e4%bd%9c%e6%88%90-%e5%88%9d%e6%ad%a9%e3%82%92%e5%be%b9%e5%ba%95%e8%a7%a3%e8%aa%ac%ef%bc%81","status":"publish","type":"post","link":"https:\/\/lovelinux.mydns.jp\/?p=243","title":{"rendered":"jQuery Plugin\u4f5c\u6210 \u521d\u6b69\u3092\u5fb9\u5e95\u89e3\u8aac\uff01"},"content":{"rendered":"<p>\u3068\u3063\u3066\u3082\u30b7\u30f3\u30d7\u30eb\u306a\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u4f5c\u308a\u307e\u3059\u3002\u305f\u3060\u3001\u3069\u3046\u3044\u3046\u4ed5\u7d44\u307f\u3067\u52d5\u3044\u3066\u3044\u308b\u304b\u3068\u3044\u3046\u306e\u3092\u4e8b\u7d30\u304b\u306b\u8a18\u8f09\u3057\u3066\u3044\u308b\u30b5\u30a4\u30c8\u306f\u5c11\u306a\u3044\u306e\u3067\u3001\u305d\u306e\u3042\u305f\u308a\u306b\u3053\u3060\u308f\u3063\u3066\u3001\u81ea\u5206\u306a\u308a\u306e\u7406\u89e3\u3092\u4e01\u5be7\u306b\u89e3\u8aac\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<p>\u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u5b8c\u6210\u30a4\u30e1\u30fc\u30b8\u306f\u3001\u3053\u3093\u306a\u611f\u3058\u3067\u3059\u3002<\/p>\n<div style=\"width: 640px;\" class=\"wp-video\"><!--[if lt IE 9]><script>document.createElement('video');<\/script><![endif]-->\n<video class=\"wp-video-shortcode\" id=\"video-243-1\" width=\"640\" height=\"360\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/ogg\" src=\"http:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2014\/02\/simpleTimer-1.ogv?_=1\" \/><a href=\"http:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2014\/02\/simpleTimer-1.ogv\">http:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2014\/02\/simpleTimer-1.ogv<\/a><\/video><\/div>\n<p>Label\u30bf\u30b0\u306b\u5bfe\u3057\u3066\u3001\u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3073\u51fa\u3059\u3068\u3001\u30bf\u30a4\u30de\u30fc\u3067\u6307\u5b9a\u3057\u305f\u9593\u9694\u3067Label\u306eText\u304c\u30ab\u30a6\u30f3\u30c8\u30a2\u30c3\u30d7\u3055\u308c\u3066\u3044\u304d\u307e\u3059\u3002\u5b9f\u969b\u306b\u547c\u3073\u51fa\u3057\u3066\u3044\u308b\u90e8\u5206\u306eHTML\u3068JavaScript\u3092\u3054\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<p>HTML<\/p>\n<p>[html]<\/p>\n<p><label id=\"counter1\" >aaa<\/label><\/p>\n<p>[\/html]<\/p>\n<p>JavaScript<\/p>\n<p>[js]<br \/>\n\t$(&#8220;#counter1&#8221;).simpleTimer();<\/p>\n<p>[\/js]<\/p>\n<p>\u3053\u308c\u3060\u3051\u3067\u3059\u3002<\/p>\n<p>\u3067\u306f\u3001\u30d7\u30e9\u30b0\u30a4\u30f3\u672c\u4f53\u306e\u30bd\u30fc\u30b9\u3092\u4ee5\u4e0b\u306b\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<p>[js]<\/p>\n<p>(function($){<\/p>\n<p>\t$.fn.simpleTimer = function(options){<br \/>\n\t\tvar target  = this;<\/p>\n<p>\t\tvar defaults = {<br \/>\n\t\t\tinterval : 1000,<br \/>\n\t\t\ttimerFunc: null<br \/>\n\t\t};<br \/>\n\t\tvar settings = $.extend(defaults, options);;<\/p>\n<p>\t\tvar elementFunc = function(elem){<br \/>\n\t\t\t\/\/init<\/p>\n<p>\t\t\tvar cnt = 0;<\/p>\n<p>\t\t\tvar init = function (){<\/p>\n<p>\t\t\t\tsetInterval(function(){<br \/>\n\t\t\t\t\t$(elem).text(cnt);<br \/>\n\t\t\t\t\tcnt++;<\/p>\n<p>\t\t\t\t\tif (settings.timerFunc != null){<br \/>\n\t\t\t\t\t\tsettings.timerFunc(elem, cnt, settings.interval);<br \/>\n\t\t\t\t\t}<\/p>\n<p>\t\t\t\t}<br \/>\n\t\t\t\t,settings.interval);<\/p>\n<p>\t\t\t\t$(elem).click(function(){<br \/>\n\t\t\t\t\tcnt = 0;<br \/>\n\t\t\t\t});<br \/>\n\t\t\t};<\/p>\n<p>\t\t\tinit();<\/p>\n<p>\t\t};<\/p>\n<p>\t\tvar ret =  $(this).each(function(){<\/p>\n<p>\t\t\telementFunc(this);<br \/>\n\t\t});<\/p>\n<p>\t\treturn ret;<br \/>\n\t}<\/p>\n<p>})(jQuery);<\/p>\n<p>[\/js]<\/p>\n<p>\u4e00\u898b\u96e3\u3057\u305d\u3046\u306b\u898b\u3048\u308b\u306e\u3067\u3001\u5206\u5272\u3057\u3066\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\n<h3>\u30d7\u30e9\u30b0\u30a4\u30f3\u540d\u306e\u6c7a\u5b9a\u3068\u3001\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u4f5c\u308b\u4e0a\u3067\u306e\u6c7a\u307e\u308a<\/h3>\n<p>\u307e\u305a\u3001 <\/p>\n<p>[js]<br \/>\n(function($){<\/p>\n<p>})(jQuery);<br \/>\n[\/js]<\/p>\n<p>\u3067\u56f2\u307f\u307e\u3059\u3002<br \/>\n\u3053\u308c\u3067\u3001\u30d7\u30e9\u30b0\u30a4\u30f3\u5185\u3068\u5916\u90e8\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u5e72\u6e09\u3092\u6291\u3048\u307e\u3059\u3002<\/p>\n<p>\u3082\u3046\u5c11\u3057\u5177\u4f53\u7684\u306b\u8a00\u3046\u3068\u3001(function($)) \u3068\u3044\u3046\u95a2\u6570\u306b\u3000\u5f15\u6570 jQuery\u3092\u6e21\u3057\u3066\u3001\u5b9f\u884c\u3057\u3066\u3044\u308b\u3068\u3044\u3046\u610f\u5473\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u3064\u307e\u308a\u3001\u5f15\u6570$ \u306b\u306f\u3000\uff4aQuery\u3068\u3044\u3046\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u98db\u3093\u3067\u304d\u3066\u3044\u3066\u3001\u3053\u306e\u95a2\u6570\u5185\u3067 $ \u3068\u66f8\u304f\u3068\u3000(jQuery)\u3068\u66f8\u3044\u3066\u3044\u308b\u306e\u3068\u540c\u7fa9\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>[js]<br \/>\n$.fn.simpleTimer = function(options){};<br \/>\n[\/js]<\/p>\n<p>\u3053\u308c\u3067 jQuery\u306b simpleTimer\u3068\u3044\u3046\u30e1\u30bd\u30c3\u30c9\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3068\u3044\u3046\u610f\u5473\u306b\u306a\u308a\u307e\u3059\u3002\uff1f\uff1f\u3061\u3087\u3044\u3068\u308f\u304b\u308a\u306b\u304f\u3044\u3067\u3059\u306d\u3002\u4e0a\u3067\u8aac\u660e\u3057\u305f\u3088\u3046\u306b $\u306f (jQuery)\u3092\u610f\u5473\u3057\u3066\u304a\u308a\u3001 $.fn \u306fjQuery\u306e\u30e1\u30bd\u30c3\u30c9\u5b9a\u7fa9\u7a7a\u9593\u3068\u306a\u3063\u3066\u3044\u307e\u3059\uff08jQuery\u306e\u4ed5\u69d8\u3067\u305d\u3046\u306a\u3063\u3066\u307e\u3059\uff09\u3002\u305d\u306e\u5b9a\u7fa9\u7a7a\u9593\u306b\u300csimpleTimer\u300d\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3000\u3068\u3044\u3046\u306e\u304c $.fn.simpleTimer \u306e\u90e8\u5206\u3067\u3059\u3002\u3067\u3001\u305d\u306esimpleTimer\u3068\u3044\u3046\u306e\u306e\u5b9f\u614b\u306f \u5f15\u6570 options\u3092\u3068\u308b function\u3067\u3059\u3088\u3001\u3068\u5b9a\u7fa9\u3057\u3066\u3044\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u3001 Label\u30bf\u30b0 ID=&#8221;aaa&#8221;\u3092\u30af\u30ea\u30c3\u30af\u3057\u305f\u3068\u3044\u3046\u306e\u3092\u5b9a\u7fa9\u3059\u308b\u5834\u5408\u306f<\/p>\n<p>[js]<\/p>\n<p>$(&#8220;#aaa&#8221;).click(function(){xxxxxx;});<\/p>\n<p>[\/js]<\/p>\n<p>\u3068\u8a18\u8f09\u3057\u307e\u3059\u3088\u306d\u3002<br \/>\n\u3053\u308c\u306f $.fn.click \u3068\u3044\u3046\u306e\u304c $.fn\u3068\u3044\u3046\u30e1\u30bd\u30c3\u30c9\u5b9a\u7fa9\u7a7a\u9593\u306b \u5b58\u5728\u3057\u3066\u3044\u308b\u3068\u3044\u3046\u610f\u5473\u3067\u3059\u3002<\/p>\n<p>jQuery\u306e\u30bd\u30fc\u30b9\u306e\u4e2d\u8eab\u3092\u30c1\u30a7\u30c3\u30af\u3057\u305f\u308f\u3051\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u304c\u3001\u30af\u30ea\u30c3\u30af\u30a4\u30d9\u30f3\u30c8\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u3057\u3087\u3046\u3002<\/p>\n<p>[js]<\/p>\n<p>jQuery.fn.click = function(){};<\/p>\n<p>[\/js]<\/p>\n<p>\u4eca\u56de\u306f click\u306e\u4ee3\u308f\u308a\u306b\u81ea\u5206\u3067\u4f5c\u308b\u30d7\u30e9\u30b0\u30a4\u30f3\u540d\u300csimpleTimer\u300d\u3068\u3044\u3046\u30e1\u30bd\u30c3\u30c9\u3092\u5b9a\u7fa9\u3057\u305f\u3068\u3044\u3046\u610f\u5473\u306b\u306a\u308a\u307e\u3059\u3002\u3053\u308c\u3067\u4f55\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u304b\u3068\u3044\u3046\u3068\u3001JavaScript\u3067 jQuery\u3067\u30a8\u30ec\u30e1\u30f3\u30c8\u6307\u5b9a\u3057\u3066\u3001\u30c9\u30c3\u30c8\u3067\u3064\u306a\u3044\u3067\u3001simpleTimer\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3073\u51fa\u305b\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002\u6587\u5b57\u3067\u66f8\u304f\u3068\u96e3\u3057\u3044\u3067\u3059\u304c\u3001\u8981\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u8a18\u8ff0\u304c\u53ef\u80fd\u306b\u306a\u3063\u305f\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002<\/p>\n<p>[js]<\/p>\n<p>$(&#8220;#aaa&#8221;).simpleTimer();<\/p>\n<p>[\/js]<\/p>\n<p>\u3053\u3053\u307e\u3067\u3001\u3054\u7406\u89e3\u3044\u305f\u3060\u3051\u307e\u3057\u305f\u304b\uff1f\u3000\u3058\u3083\u3041\u6b21\u306b\u884c\u3063\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<h3>\u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u5b9f\u884c\u3068\u623b\u308a\u5024\uff08\u30e1\u30bd\u30c3\u30c9\u30c1\u30a7\u30fc\u30f3\u3092\u53ef\u80fd\u306b\u3059\u308b\uff09<\/h3>\n<p>[js]<br \/>\n(function($){<\/p>\n<p>\t$.fn.simpleTimer = function(options){<\/p>\n<p>\t\tvar elementFunc = function(elem,options){<br \/>\n\t\t};<\/p>\n<p>\t\tvar ret =  $(this).each(function(){<br \/>\n\t\t    elementFunc(this);<br \/>\n\t\t});<\/p>\n<p>\t\treturn ret;<br \/>\n\t};<\/p>\n<p>})(jQuery);<br \/>\n[\/js]<\/p>\n<p>\u306a\u3093\u3060\u304b\u5c0f\u96e3\u3057\u3044\u3067\u3059\u306d\u3002simpleTimer\u3068\u3044\u3046\u30e1\u30bd\u30c3\u30c9\u3092 \u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u4f7f\u3046\u4eba\u304c<\/p>\n<p>[js]<br \/>\n$(&#8220;#aaa&#8221;).simpleTimer();<br \/>\n[\/js]<\/p>\n<p>\u3068\u547c\u3073\u3060\u3059\u3068\u3001\u4f55\u3089\u304b\u306e\u51e6\u7406\u3092\u5b9f\u884c\u3057\u3066\u3001\u623b\u308a\u5024\u3092\u623b\u3057\u3066\u3044\u308b\u3068\u3044\u3046\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002\u305d\u3057\u3066\u3001 $(this).each(function(){elementFunc(this);});<\/p>\n<p>\u3068\u3044\u3046\u90e8\u5206\u3002<\/p>\n<p>\u307e\u305a\u3001jQuery\u30d7\u30e9\u30b0\u30a4\u30f3\u306b\u304a\u3044\u3066\u3001this \u306b\u306f\u3001\u6307\u5b9a\u3055\u308c\u305f DOM\u30a8\u30ec\u30e1\u30f3\u30c8\u304c\u5165\u3063\u3066\u304f\u308b\u3068\u3044\u3046\u6c7a\u307e\u308a\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<br \/>\n\u3064\u307e\u308a\u3001\u4eca\u56de\u306e\u4f8b\u3067\u3044\u3046\u3068 this\u306f\u3000ID = &#8220;aaa&#8221; \u3068\u3044\u3046DOM\u30a8\u30ec\u30e1\u30f3\u30c8\u3068\u3044\u3046\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>$(this)\u3068\u306f\u3001 ID = &#8220;aaa&#8221;\u3000\u306b\u5bfe\u5fdc\u3059\u308b jQuery\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3068\u3044\u3046\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002\u305d\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u5bfe\u3057\u3066\u3001jQuery\u306eeach\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3073\u51fa\u3057\u3066\u3044\u308b\u3068\u3002\u4e00\u822c\u7684\u306b\u306fID\u6307\u5b9a\u3059\u308b\u3068\uff11\u3064\u306eDOM\u30a8\u30ec\u30e1\u30f3\u30c8\u3068\u306a\u308a\u307e\u3059\u304c\u3001ID = &#8220;aaa&#8221;\u306e\u30a8\u30ec\u30e1\u30f3\u30c8\u304c\u8907\u6570\u3042\u308b\u5834\u5408\u3001$(this)\u306f\u3001\u8907\u6570\u306e\u30a8\u30ec\u30e1\u30f3\u30c8\u3092\u6307\u3057\u3066\u3044\u308b\u3068\u3044\u3046\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002\u305d\u306e\u8907\u6570\u306e\u30a8\u30ec\u30e1\u30f3\u30c8\u306b\u5bfe\u3057\u3066\u3001jQuery\u306eeach\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3093\u3067\u3044\u308b\u3068\u3044\u3046\u610f\u5473\u3067\u3059\u306d\u3002\u3067\u3001\u4f55\u3092\u5b9f\u884c\u3059\u308b\u304b\u3068\u3044\u3046\u3068\u3001\u30d7\u30e9\u30b0\u30a4\u30f3\u672c\u4f53\u30e1\u30bd\u30c3\u30c9 elementFunc\u3092\u547c\u3073\u51fa\u3057\u3066\u3044\u308b\u3068\u3044\u3046\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002\u3053\u3053\u3067\u6ce8\u610f\u3057\u3066\u3044\u305f\u3060\u304d\u305f\u3044\u306e\u304c\u3001<\/p>\n<p>\u3053\u3053\u306e this\u306f ID = &#8220;aaa&#8221; \u306eDOM\u30a8\u30ec\u30e1\u30f3\u30c8\uff08\u8907\u6570\u306e\u30a8\u30ec\u30e1\u30f3\u30c8\u306b\u306a\u308b\u30b1\u30fc\u30b9\u3042\u308a\uff09<br \/>\n[js]<br \/>\nvar ret =  $(this).each(function(){<br \/>\n[\/js]<\/p>\n<p>\u3053\u3053\u306ethis\u306f\u3001 ID = &#8220;aaa&#8221; \u306eDOM\u30a8\u30ec\u30e1\u30f3\u30c8\uff08<b>\u500b\u5225\u306e\u30a8\u30ec\u30e1\u30f3\u30c8\uff01\uff01<\/b>\uff09<\/p>\n<p>[js]<br \/>\nelementFunc(this);<br \/>\n[\/js]<\/p>\n<p>\u3068\u3044\u3046\u9055\u3044\u304c\u3042\u308b\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002<\/p>\n<p>\u8981\u306f\u3001jQuery(\u30bb\u30ec\u30af\u30bf\u30fc\uff09.simpleTimer()\u3000\u3067\u6307\u5b9a\u3055\u308c\u305f\u30bb\u30ec\u30af\u30bf\u30fc\u306b\u5f53\u3066\u306f\u307e\u308b DOM\u30a8\u30ec\u30e1\u30f3\u30c8\uff11\u3064\uff11\u3064\u306b\u5bfe\u3057\u3066\u3001elementFunc\u3092\u5b9f\u884c\u3059\u308b\u3088\uff01\u3068\u3044\u3046\u610f\u5473\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001<\/p>\n<p>[js]<br \/>\nvar ret =  $(this).each()<\/p>\n<p>return ret;<br \/>\n[\/js]<\/p>\n<p>jQuery\u306eeach\u30e1\u30bd\u30c3\u30c9\u306f\u3000\u5f15\u6570\u306b\u4e0e\u3048\u3089\u308c\u305ffunction\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002\u304c\u3001\u623b\u308a\u5024\u306f\u3001\u5b9f\u884c\u3059\u308bfunction\u306e\u5185\u5bb9\u306b\u304b\u304b\u308f\u3089\u305a\u3001jQuery\u30bb\u30ec\u30af\u30bf\u30fc\u3068\u306a\u308a\u307e\u3059\u3002\u3064\u307e\u308a\u4eca\u56de\u306e\u5834\u5408\u306f\u623b\u308a\u5024\u304c\u3001 $(this)\u306b\u306a\u308b\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002\u3053\u3046\u3059\u308b\u3053\u3068\u3067\u3069\u3093\u306a\u30e1\u30ea\u30c3\u30c8\u304c\u3042\u308b\u304b\u3068\u3044\u3046\u3068\u3001\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u5229\u7528\u3059\u308b\u4eba\u304c\u30e1\u30bd\u30c3\u30c9\u30c1\u30a7\u30fc\u30f3\u3092\u5229\u7528\u3067\u304d\u308b\u3068\u3044\u3046\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u3082\u3063\u3068\u5177\u4f53\u7684\u306b\u3044\u3046\u3068\u3001\u3053\u3093\u306a\u8a18\u8ff0\u304c\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3088\uff01\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002<\/p>\n<p>[js]<br \/>\n\t$(&#8220;#aaa&#8221;).simpleTimer().click(function(){xxxxx;});<br \/>\n[\/js]<\/p>\n<h3>\u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u6a5f\u80fd\uff08\u5b9f\u884c\u3059\u308b\u51e6\u7406\uff09<\/h3>\n<p>\u3067\u306f\u3001\u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u30e1\u30a4\u30f3\u30eb\u30fc\u30c1\u30f3 elementFunc\u306b\u3064\u3044\u3066\u3001\u89e3\u8aac\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<p>[js]<br \/>\n\t\tvar elementFunc = function(elem){<br \/>\n\t\t\t\/\/init<\/p>\n<p>\t\t\tvar cnt = 0;<\/p>\n<p>\t\t\tvar init = function (){<\/p>\n<p>\t\t\t\tsetInterval(function(){<br \/>\n\t\t\t\t\t$(elem).text(cnt);<br \/>\n\t\t\t\t\tcnt++;<\/p>\n<p>\t\t\t\t\tif (settings.timerFunc != null){<br \/>\n\t\t\t\t\t\tsettings.timerFunc(elem, cnt, settings.interval);<br \/>\n\t\t\t\t\t}<\/p>\n<p>\t\t\t\t}<br \/>\n\t\t\t\t,settings.interval);<\/p>\n<p>\t\t\t\t$(elem).click(function(){<br \/>\n\t\t\t\t\tcnt = 0;<br \/>\n\t\t\t\t});<br \/>\n\t\t\t};<\/p>\n<p>\t\t\tinit();<\/p>\n<p>\t\t};<\/p>\n<p>[\/js]<\/p>\n<p>\u3053\u308c\u306f\u3001\u4f55\u3082\u8907\u96d1\u306b\u8003\u3048\u308b\u5fc5\u8981\u3082\u306a\u3044\u3001\u30b7\u30f3\u30d7\u30eb\u306a JavaScript\u306e\u95a2\u6570\u3067\u3059\u3002\u5f15\u6570\u306felem\u3067\u3059\u3002<\/p>\n<ul>\n<li>\u95a2\u6570\u306e\u5148\u982d\u3067 cnt\u3068\u3044\u3046\u6570\u5024\u578b\u306e\u5909\u6570\u3092\u5ba3\u8a00\u3057\u3001\uff10\u3067\u521d\u671f\u5316\u3057\u307e\u3059\u3002<\/li>\n<li>\u6b21\u306b\u3000\u5185\u90e8\u95a2\u6570 init \u3092\u547c\u3073\u51fa\u3057\u307e\u3059\u3002<\/li>\n<li> init\u95a2\u6570\u306f setInterval\u3067\u30bf\u30a4\u30de\u30fc\u51e6\u7406\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002\u30bf\u30a4\u30de\u30fc\u306e\u5b9f\u884c\u9593\u9694\u306f\u3001 settings.interval\u3067\u3059\u3002\u5b9f\u884c\u3059\u308b\u4e2d\u8eab\u306f\u3001\u5f15\u6570\u3067\u4e0e\u3048\u3089\u308c\u305f DOM\u30a8\u30ec\u30e1\u30f3\u30c8\u306eText\u306b\u5909\u6570 cnt\u3092\u30bb\u30c3\u30c8\u3059\u308b\u3068\u3044\u3046\u3001\u81f3\u3063\u3066\u30b7\u30f3\u30d7\u30eb\u306a\u4f5c\u308a\u3067\u3059\u3002\u305d\u3057\u3066Text\u306e\u5024\u3092\u5909\u66f4\u3057\u305f\u5f8c\u306b cnt\u5909\u6570\u3092\u30ab\u30a6\u30f3\u30c8\u30a2\u30c3\u30d7\u3057\u307e\u3059\u3002\u305d\u3057\u3066\u3000settings.timerFunc\u3068\u3044\u3046\u5909\u6570\u304cnull\u3067\u306a\u3051\u308c\u3070\u3001settings.timerFunc\u3092\u5b9f\u884c\u3059\u308b\u3002\u6700\u5f8c\u306b\u3082\u3057 elem\u304c\u30af\u30ea\u30c3\u30af\u3055\u308c\u305f\u3089\u3001cnt\u3092\uff10\u306b\u623b\u3059\u3068\u3044\u3046\u51e6\u7406\u304c\u8a18\u8ff0\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/li>\n<\/ul>\n<h3>\u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u5f15\u6570<\/h3>\n<p>\u3055\u3066\u3001\u95a2\u6570\u306e\u5185\u90e8\u3067 settings\u3068\u51fa\u3066\u304d\u307e\u3057\u305f\u304c\u3001\u3053\u308c\u306f\u4f55\u8005\u3067\u3057\u3087\u3046\u304b\uff1f\u3053\u308c\u306f\u3001simpleTimer\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3073\u51fa\u3059\u3068\u304d\u306b\u6307\u5b9a\u3057\u305f\u30aa\u30d7\u30b7\u30e7\u30f3\u5f15\u6570\u306e\u4e2d\u8eab\u3068\u306a\u308a\u307e\u3059\u3002\u5177\u4f53\u7684\u306a\u30bd\u30fc\u30b9\u3067\u3044\u3046\u3068\u4ee5\u4e0b\u306e\u90e8\u5206\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>[js]<br \/>\n\t$.fn.simpleTimer = function(options){<br \/>\n\t\tvar target  = this;<\/p>\n<p>\t\tvar defaults = {<br \/>\n\t\t\tinterval : 1000,<br \/>\n\t\t\ttimerFunc: null<br \/>\n\t\t};<br \/>\n\t\tvar settings = $.extend(defaults, options);;<br \/>\n[\/js]<\/p>\n<p>options\u306b\u306f\u3001\u30d7\u30e9\u30b0\u30a4\u30f3\u547c\u3073\u51fa\u3057\u6642\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5f15\u6570\u3092\u4e0e\u3048\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>[js]<br \/>\n\t$(&#8220;#aaa&#8221;).simpleTimer({aaa:&#8221;hello&#8221;,bbb:&#8221;goodbye&#8221;});<\/p>\n<p>[\/js]<\/p>\n<p>\u30d7\u30e9\u30b0\u30a4\u30f3\u5185\u90e8\u3067\u306f\u3001\u6e21\u3055\u308c\u305f\u5f15\u6570\u3068\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u3092\u3001jQuery\u306e\u6a5f\u80fd $.extend\u3067\u30de\u30fc\u30b8\u3057\u3001\u305d\u306e\u7d50\u679c\u3092 settings\u3068\u3044\u3046\u30d7\u30e9\u30b0\u30a4\u30f3\u5185\u90e8\u3067\u5229\u7528\u53ef\u80fd\u306a\u5909\u6570\u306b\u30bb\u30c3\u30c8\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u4eca\u56de\u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u3067\u306f\u3001\u30bf\u30a4\u30de\u30fc\u306e\u51e6\u7406\u9593\u9694\u306e\u521d\u671f\u5024\u3092\uff11\uff10\uff10\uff10\uff08\u3064\u307e\u308a\uff11\u79d2\uff09\u3001\u30bf\u30a4\u30de\u30fc\u5b9f\u884c\u6642\u306b\u547c\u3073\u51fa\u3059function\u3092null\uff08\u3064\u307e\u308a\u4f55\u3082\u547c\u3073\u51fa\u3055\u306a\u3044\uff09\u304c\u521d\u671f\u5024\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3082\u3057\u3001\u5b9f\u884c\u9593\u9694\u3092\u4f38\u3070\u3057\u305f\u3044\u3068\u3044\u3046\u5834\u5408\u306f\u3001\u547c\u3073\u51fa\u3059\u969b\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u8a18\u8ff0\u3092\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<p>[js]<br \/>\n\t$(&#8220;#aaa&#8221;).simpleTimer({interval: 5000});<\/p>\n<p>[\/js]<\/p>\n<p>\u3053\u308c\u3067\uff15\u79d2\u6bce\u306b\u30bf\u30a4\u30de\u30fc\u304c\u5b9f\u884c\u3055\u308c\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002\u52a0\u3048\u3066\u3001\u30bf\u30a4\u30de\u30fc\u51e6\u7406\u6642\u306b\u72ec\u81ea\u306e\u51e6\u7406\u3092\u5b9f\u884c\u3057\u305f\u3044\u3068\u3044\u3046\u5834\u5408\u306b\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u8a18\u8ff0\u3067\u5bfe\u5fdc\u53ef\u80fd\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>[js]<br \/>\n\t$(&#8220;#aaa&#8221;).simpleTimer({timerFunc: function(elem,count,interval){<br \/>\n\t\t\/\/\u4f55\u3089\u304b\u306e\u51e6\u7406<br \/>\n\t\tvar msg = &#8220;Debug from user script&#8221;;<br \/>\n\t\tmsg += &#8220;ElementId = &#8221; + elem.id;<br \/>\n\t\tmsg += &#8221; count = &#8221; + count;<br \/>\n\t\tmsg += &#8221; \/interval info = &#8221; + interval;<\/p>\n<p>\t\tconsole.log(msg);<br \/>\n\t});<\/p>\n<p>[\/js]<\/p>\n<h3>\u5b8c\u6210\u30a4\u30e1\u30fc\u30b8\u78ba\u8a8d<\/h3>\n<p>\u3067\u306f\u3001\u518d\u5ea6\u5b8c\u6210\u30a4\u30e1\u30fc\u30b8\u306e\u30d3\u30c7\u30aa\u3092\u898b\u3066\u3001\u3069\u3093\u306a\u611f\u3058\u3067\u51e6\u7406\u304c\u884c\u308f\u308c\u3066\u3044\u308b\u304b\u78ba\u8a8d\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<div style=\"width: 640px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-243-2\" width=\"640\" height=\"360\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/ogg\" src=\"http:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2014\/02\/simpleTimer-1.ogv?_=2\" \/><a href=\"http:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2014\/02\/simpleTimer-1.ogv\">http:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2014\/02\/simpleTimer-1.ogv<\/a><\/video><\/div>\n<p>\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u5229\u7528\u3059\u308bHTML\u3068JavaScript\u306e\u30bd\u30fc\u30b9\u3067\u3059\u3002<br \/>\n\u30d3\u30c7\u30aa\u3067\u78ba\u8a8d\u3059\u308b\u3068\u3001\u30bf\u30a4\u30de\u30fc\u304c\u5b9f\u884c\u3055\u308c\u3066\u3001\u30ab\u30a6\u30f3\u30c8\u30a2\u30c3\u30d7\u304c\u59cb\u307e\u308a\u3001Label\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u3001\u30af\u30ea\u30c3\u30af\u3055\u308c\u305fLabel\u306e\u307f\u3001\u30ab\u30a6\u30f3\u30bf\u30fc\u304c\u521d\u671f\u5316\u3055\u308c\u3066\u3044\u308b\u306e\u304c\u78ba\u8a8d\u3067\u304d\u308b\u3068\u601d\u3044\u307e\u3059\u3002\u307e\u305f\u3001 #counter1\u306b\u306f\u3001\u30bf\u30a4\u30de\u30fc\u5b9f\u884c\u6642\u306b\u547c\u3073\u51fa\u3059\u30e1\u30bd\u30c3\u30c9\u3092\u5b9a\u7fa9\u3057\u3001\u30e1\u30bd\u30c3\u30c9\u5185\u3067\u30b3\u30f3\u30bd\u30fc\u30eb\u51fa\u529b\u3092\u884c\u3063\u3066\u3044\u308b\u306e\u3067\u3001\u3054\u81ea\u8eab\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u5b9f\u884c\u74b0\u5883\u3067\u30b3\u30f3\u30bd\u30fc\u30eb\u30ed\u30b0\u3082\u78ba\u8a8d\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>[html]<\/p>\n<p><label id=\"counter1\" >aaa<\/label><br \/>\n<label id=\"counter2\" class=\"hogehoge\">bbb<\/label><br \/>\n<label id=\"counter3\" class=\"hogehoge\">ccc<\/label><\/p>\n<p>[\/html]<\/p>\n<p>[js]<br \/>\n$(function(){<\/p>\n<p>\t$(&#8220;#counter1&#8221;).simpleTimer({interval:1000,timerFunc:function(elem, count,interval){<br \/>\n\t\t\tvar msg = &#8220;Debug from user script&#8221;;<br \/>\n\t\t\tmsg += &#8220;ElementId = &#8221; + elem.id;<br \/>\n\t\t\tmsg += &#8221; count = &#8221; + count;<br \/>\n\t\t\tmsg += &#8221; \/interval info = &#8221; + interval;<\/p>\n<p>\t\t\tconsole.log(msg);<\/p>\n<p>\t\t}<br \/>\n\t}).click(function(){<br \/>\n\t\t$(this).text(&#8220;clicked&#8221;);<br \/>\n\t});<\/p>\n<p>\t$(&#8220;label.hogehoge&#8221;).simpleTimer().click(function(){<br \/>\n\t\t$(this).text(&#8220;hogehoge clicked&#8221;);<\/p>\n<p>\t});<br \/>\n});<\/p>\n<p>[\/js]<\/p>\n<p>\u4ee5\u4e0a\u3068\u306a\u308a\u307e\u3059\u3002<br \/>\n\u30d7\u30e9\u30b0\u30a4\u30f3\u306b\u306f\u3044\u308d\u3093\u306a\u8a18\u8ff0\u65b9\u6cd5\u304c\u3042\u308b\u307f\u305f\u3044\u3067\u3059\u304c\u3001\u81ea\u5206\u306e\u304a\u6c17\u306b\u5165\u308a\u3067\u7406\u89e3\u3057\u3084\u3059\u3044\u65b9\u6cd5\u3092\uff11\u3064\u30de\u30b9\u30bf\u30fc\u3059\u308c\u3070OK\u3060\u3068\u601d\u3044\u307e\u3059\u3002\u4eca\u56de\u306e\u4f8b\u306f\u305d\u306e\uff11\u30d1\u30bf\u30fc\u30f3\u306b\u306a\u308a\u307e\u3059\u3002\u826f\u3051\u308c\u3070\u53c2\u8003\u306b\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3068\u3063\u3066\u3082\u30b7\u30f3\u30d7\u30eb\u306a\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u4f5c\u308a\u307e\u3059\u3002\u305f\u3060\u3001\u3069\u3046\u3044\u3046\u4ed5\u7d44\u307f\u3067\u52d5\u3044\u3066\u3044\u308b\u304b\u3068\u3044\u3046\u306e\u3092\u4e8b\u7d30\u304b\u306b\u8a18\u8f09\u3057\u3066\u3044\u308b\u30b5\u30a4\u30c8\u306f\u5c11\u306a\u3044\u306e\u3067\u3001\u305d\u306e\u3042\u305f\u308a\u306b\u3053\u3060\u308f\u3063\u3066\u3001\u81ea\u5206\u306a\u308a\u306e\u7406\u89e3\u3092\u4e01\u5be7\u306b\u89e3\u8aac\u3057\u3066\u307f\u307e\u3059\u3002 \u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u5b8c\u6210\u30a4\u30e1\u30fc\u30b8\u306f\u3001\u3053\u3093\u306a\u611f\u3058\u3067\u3059\u3002 Label\u30bf\u30b0\u306b\u5bfe\u3057\u3066\u3001\u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3073\u51fa\u3059\u3068\u3001\u30bf\u30a4\u30de\u30fc\u3067\u6307\u5b9a\u3057\u305f\u9593\u9694\u3067Label\u306eText\u304c\u30ab\u30a6\u30f3\u30c8\u30a2\u30c3\u30d7\u3055\u308c\u3066\u3044\u304d\u307e\u3059\u3002\u5b9f\u969b\u306b\u547c\u3073\u51fa\u3057\u3066\u3044\u308b\u90e8\u5206\u306eHTML\u3068JavaScript\u3092\u3054\u7d39\u4ecb\u3057\u307e\u3059\u3002 HTML [html] aaa [\/html] JavaScript [js] $(&#8220;#counter1&#8221;).simpleTimer(); [\/js] \u3053\u308c\u3060\u3051\u3067\u3059\u3002 \u3067\u306f\u3001\u30d7\u30e9\u30b0\u30a4\u30f3\u672c\u4f53\u306e\u30bd\u30fc\u30b9\u3092\u4ee5\u4e0b\u306b\u7d39\u4ecb\u3057\u307e\u3059\u3002 [js] (function($){ $.fn.simpleTimer = function(options){ var target = this; var defaults = { interval : 1000, timerFunc: null }; var settings = $.extend(defaults, options);; var elementFunc = function(elem){ \/\/init var cnt = 0; var init = function (){ setInterval(function(){ $(elem).text(cnt); cnt++; if (settings.timerFunc != null){ settings.timerFunc(elem, cnt, settings.interval); } } ,settings.interval); $(elem).click(function(){ cnt = 0; }); }; init(); }; var ret = $(this).each(function(){ elementFunc(this); }); return ret; } })(jQuery); [\/js] \u4e00\u898b\u96e3\u3057\u305d\u3046\u306b\u898b\u3048\u308b\u306e\u3067\u3001\u5206\u5272\u3057\u3066\u8aac\u660e\u3057\u307e\u3059\u3002 \u30d7\u30e9\u30b0\u30a4\u30f3\u540d\u306e\u6c7a\u5b9a\u3068\u3001\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u4f5c\u308b\u4e0a\u3067\u306e\u6c7a\u307e\u308a \u307e\u305a\u3001 [js] (function($){ })(jQuery); [\/js] \u3067\u56f2\u307f\u307e\u3059\u3002 \u3053\u308c\u3067\u3001\u30d7\u30e9\u30b0\u30a4\u30f3\u5185\u3068\u5916\u90e8\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u5e72\u6e09\u3092\u6291\u3048\u307e\u3059\u3002 \u3082\u3046\u5c11\u3057\u5177\u4f53\u7684\u306b\u8a00\u3046\u3068\u3001(function($)) \u3068\u3044\u3046\u95a2\u6570\u306b\u3000\u5f15\u6570 jQuery\u3092\u6e21\u3057\u3066\u3001\u5b9f\u884c\u3057\u3066\u3044\u308b\u3068\u3044\u3046\u610f\u5473\u306b\u306a\u308a\u307e\u3059\u3002 \u3064\u307e\u308a\u3001\u5f15\u6570$ \u306b\u306f\u3000\uff4aQuery\u3068\u3044\u3046\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u98db\u3093\u3067\u304d\u3066\u3044\u3066\u3001\u3053\u306e\u95a2\u6570\u5185\u3067 $ \u3068\u66f8\u304f\u3068\u3000(jQuery)\u3068\u66f8\u3044\u3066\u3044\u308b\u306e\u3068\u540c\u7fa9\u306b\u306a\u308a\u307e\u3059\u3002 [js] $.fn.simpleTimer = function(options){}; [\/js] \u3053\u308c\u3067 jQuery\u306b simpleTimer\u3068\u3044\u3046\u30e1\u30bd\u30c3\u30c9\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3068\u3044\u3046\u610f\u5473\u306b\u306a\u308a\u307e\u3059\u3002\uff1f\uff1f\u3061\u3087\u3044\u3068\u308f\u304b\u308a\u306b\u304f\u3044\u3067\u3059\u306d\u3002\u4e0a\u3067\u8aac\u660e\u3057\u305f\u3088\u3046\u306b $\u306f (jQuery)\u3092\u610f\u5473\u3057\u3066\u304a\u308a\u3001 $.fn \u306fjQuery\u306e\u30e1\u30bd\u30c3\u30c9\u5b9a\u7fa9\u7a7a\u9593\u3068\u306a\u3063\u3066\u3044\u307e\u3059\uff08jQuery\u306e\u4ed5\u69d8\u3067\u305d\u3046\u306a\u3063\u3066\u307e\u3059\uff09\u3002\u305d\u306e\u5b9a\u7fa9\u7a7a\u9593\u306b\u300csimpleTimer\u300d\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3000\u3068\u3044\u3046\u306e\u304c $.fn.simpleTimer \u306e\u90e8\u5206\u3067\u3059\u3002\u3067\u3001\u305d\u306esimpleTimer\u3068\u3044\u3046\u306e\u306e\u5b9f\u614b\u306f \u5f15\u6570 options\u3092\u3068\u308b function\u3067\u3059\u3088\u3001\u3068\u5b9a\u7fa9\u3057\u3066\u3044\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002 \u4f8b\u3048\u3070\u3001 Label\u30bf\u30b0 ID=&#8221;aaa&#8221;\u3092\u30af\u30ea\u30c3\u30af\u3057\u305f\u3068\u3044\u3046\u306e\u3092\u5b9a\u7fa9\u3059\u308b\u5834\u5408\u306f [js] $(&#8220;#aaa&#8221;).click(function(){xxxxxx;}); [\/js] \u3068\u8a18\u8f09\u3057\u307e\u3059\u3088\u306d\u3002 \u3053\u308c\u306f $.fn.click \u3068\u3044\u3046\u306e\u304c $.fn\u3068\u3044\u3046\u30e1\u30bd\u30c3\u30c9\u5b9a\u7fa9\u7a7a\u9593\u306b \u5b58\u5728\u3057\u3066\u3044\u308b\u3068\u3044\u3046\u610f\u5473\u3067\u3059\u3002 jQuery\u306e\u30bd\u30fc\u30b9\u306e\u4e2d\u8eab\u3092\u30c1\u30a7\u30c3\u30af\u3057\u305f\u308f\u3051\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u304c\u3001\u30af\u30ea\u30c3\u30af\u30a4\u30d9\u30f3\u30c8\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u3057\u3087\u3046\u3002 [js] jQuery.fn.click = function(){}; [\/js] \u4eca\u56de\u306f click\u306e\u4ee3\u308f\u308a\u306b\u81ea\u5206\u3067\u4f5c\u308b\u30d7\u30e9\u30b0\u30a4\u30f3\u540d\u300csimpleTimer\u300d\u3068\u3044\u3046\u30e1\u30bd\u30c3\u30c9\u3092\u5b9a\u7fa9\u3057\u305f\u3068\u3044\u3046\u610f\u5473\u306b\u306a\u308a\u307e\u3059\u3002\u3053\u308c\u3067\u4f55\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u304b\u3068\u3044\u3046\u3068\u3001JavaScript\u3067 jQuery\u3067\u30a8\u30ec\u30e1\u30f3\u30c8\u6307\u5b9a\u3057\u3066\u3001\u30c9\u30c3\u30c8\u3067\u3064\u306a\u3044\u3067\u3001simpleTimer\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3073\u51fa\u305b\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002\u6587\u5b57\u3067\u66f8\u304f\u3068\u96e3\u3057\u3044\u3067\u3059\u304c\u3001\u8981\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u8a18\u8ff0\u304c\u53ef\u80fd\u306b\u306a\u3063\u305f\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002 [js] $(&#8220;#aaa&#8221;).simpleTimer(); [\/js] \u3053\u3053\u307e\u3067\u3001\u3054\u7406\u89e3\u3044\u305f\u3060\u3051\u307e\u3057\u305f\u304b\uff1f\u3000\u3058\u3083\u3041\u6b21\u306b\u884c\u3063\u3066\u307f\u307e\u3057\u3087\u3046\u3002 \u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u5b9f\u884c\u3068\u623b\u308a\u5024\uff08\u30e1\u30bd\u30c3\u30c9\u30c1\u30a7\u30fc\u30f3\u3092\u53ef\u80fd\u306b\u3059\u308b\uff09 [js] (function($){ $.fn.simpleTimer = function(options){ var elementFunc = function(elem,options){ }; var ret = $(this).each(function(){ elementFunc(this); }); return ret; }; })(jQuery); [\/js] \u306a\u3093\u3060\u304b\u5c0f\u96e3\u3057\u3044\u3067\u3059\u306d\u3002simpleTimer\u3068\u3044\u3046\u30e1\u30bd\u30c3\u30c9\u3092 \u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u4f7f\u3046\u4eba\u304c [js] $(&#8220;#aaa&#8221;).simpleTimer(); [\/js] \u3068\u547c\u3073\u3060\u3059\u3068\u3001\u4f55\u3089\u304b\u306e\u51e6\u7406\u3092\u5b9f\u884c\u3057\u3066\u3001\u623b\u308a\u5024\u3092\u623b\u3057\u3066\u3044\u308b\u3068\u3044\u3046\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002\u305d\u3057\u3066\u3001 $(this).each(function(){elementFunc(this);}); \u3068\u3044\u3046\u90e8\u5206\u3002 \u307e\u305a\u3001jQuery\u30d7\u30e9\u30b0\u30a4\u30f3\u306b\u304a\u3044\u3066\u3001this \u306b\u306f\u3001\u6307\u5b9a\u3055\u308c\u305f DOM\u30a8\u30ec\u30e1\u30f3\u30c8\u304c\u5165\u3063\u3066\u304f\u308b\u3068\u3044\u3046\u6c7a\u307e\u308a\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002 \u3064\u307e\u308a\u3001\u4eca\u56de\u306e\u4f8b\u3067\u3044\u3046\u3068 this\u306f\u3000ID = &#8220;aaa&#8221; \u3068\u3044\u3046DOM\u30a8\u30ec\u30e1\u30f3\u30c8\u3068\u3044\u3046\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002 $(this)\u3068\u306f\u3001 ID = &#8220;aaa&#8221;\u3000\u306b\u5bfe\u5fdc\u3059\u308b jQuery\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3068\u3044\u3046\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002\u305d\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u5bfe\u3057\u3066\u3001jQuery\u306eeach\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3073\u51fa\u3057\u3066\u3044\u308b\u3068\u3002\u4e00\u822c\u7684\u306b\u306fID\u6307\u5b9a\u3059\u308b\u3068\uff11\u3064\u306eDOM\u30a8\u30ec\u30e1\u30f3\u30c8\u3068\u306a\u308a\u307e\u3059\u304c\u3001ID = &#8220;aaa&#8221;\u306e\u30a8\u30ec\u30e1\u30f3\u30c8\u304c\u8907\u6570\u3042\u308b\u5834\u5408\u3001$(this)\u306f\u3001\u8907\u6570\u306e\u30a8\u30ec\u30e1\u30f3\u30c8\u3092\u6307\u3057\u3066\u3044\u308b\u3068\u3044\u3046\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002\u305d\u306e\u8907\u6570\u306e\u30a8\u30ec\u30e1\u30f3\u30c8\u306b\u5bfe\u3057\u3066\u3001jQuery\u306eeach\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3093\u3067\u3044\u308b\u3068\u3044\u3046\u610f\u5473\u3067\u3059\u306d\u3002\u3067\u3001\u4f55\u3092\u5b9f\u884c\u3059\u308b\u304b\u3068\u3044\u3046\u3068\u3001\u30d7\u30e9\u30b0\u30a4\u30f3\u672c\u4f53\u30e1\u30bd\u30c3\u30c9 elementFunc\u3092\u547c\u3073\u51fa\u3057\u3066\u3044\u308b\u3068\u3044\u3046\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002\u3053\u3053\u3067\u6ce8\u610f\u3057\u3066\u3044\u305f\u3060\u304d\u305f\u3044\u306e\u304c\u3001 \u3053\u3053\u306e this\u306f ID = &#8220;aaa&#8221; \u306eDOM\u30a8\u30ec\u30e1\u30f3\u30c8\uff08\u8907\u6570\u306e\u30a8\u30ec\u30e1\u30f3\u30c8\u306b\u306a\u308b\u30b1\u30fc\u30b9\u3042\u308a\uff09 [js] var ret = $(this).each(function(){ [\/js] \u3053\u3053\u306ethis\u306f\u3001 ID = &#8220;aaa&#8221; \u306eDOM\u30a8\u30ec\u30e1\u30f3\u30c8\uff08\u500b\u5225\u306e\u30a8\u30ec\u30e1\u30f3\u30c8\uff01\uff01\uff09 [js] elementFunc(this); [\/js] \u3068\u3044\u3046\u9055\u3044\u304c\u3042\u308b\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002 \u8981\u306f\u3001jQuery(\u30bb\u30ec\u30af\u30bf\u30fc\uff09.simpleTimer()\u3000\u3067\u6307\u5b9a\u3055\u308c\u305f\u30bb\u30ec\u30af\u30bf\u30fc\u306b\u5f53\u3066\u306f\u307e\u308b DOM\u30a8\u30ec\u30e1\u30f3\u30c8\uff11\u3064\uff11\u3064\u306b\u5bfe\u3057\u3066\u3001elementFunc\u3092\u5b9f\u884c\u3059\u308b\u3088\uff01\u3068\u3044\u3046\u610f\u5473\u306b\u306a\u308a\u307e\u3059\u3002 \u305d\u3057\u3066\u3001 [js] var ret = $(this).each() return ret; [\/js] jQuery\u306eeach\u30e1\u30bd\u30c3\u30c9\u306f\u3000\u5f15\u6570\u306b\u4e0e\u3048\u3089\u308c\u305ffunction\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002\u304c\u3001\u623b\u308a\u5024\u306f\u3001\u5b9f\u884c\u3059\u308bfunction\u306e\u5185\u5bb9\u306b\u304b\u304b\u308f\u3089\u305a\u3001jQuery\u30bb\u30ec\u30af\u30bf\u30fc\u3068\u306a\u308a\u307e\u3059\u3002\u3064\u307e\u308a\u4eca\u56de\u306e\u5834\u5408\u306f\u623b\u308a\u5024\u304c\u3001 $(this)\u306b\u306a\u308b\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002\u3053\u3046\u3059\u308b\u3053\u3068\u3067\u3069\u3093\u306a\u30e1\u30ea\u30c3\u30c8\u304c\u3042\u308b\u304b\u3068\u3044\u3046\u3068\u3001\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u5229\u7528\u3059\u308b\u4eba\u304c\u30e1\u30bd\u30c3\u30c9\u30c1\u30a7\u30fc\u30f3\u3092\u5229\u7528\u3067\u304d\u308b\u3068\u3044\u3046\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002 \u3082\u3063\u3068\u5177\u4f53\u7684\u306b\u3044\u3046\u3068\u3001\u3053\u3093\u306a\u8a18\u8ff0\u304c\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3088\uff01\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002 [js] $(&#8220;#aaa&#8221;).simpleTimer().click(function(){xxxxx;}); [\/js] \u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u6a5f\u80fd\uff08\u5b9f\u884c\u3059\u308b\u51e6\u7406\uff09 \u3067\u306f\u3001\u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u30e1\u30a4\u30f3\u30eb\u30fc\u30c1\u30f3 elementFunc\u306b\u3064\u3044\u3066\u3001\u89e3\u8aac\u3057\u3066\u304a\u304d\u307e\u3059\u3002 [js] var elementFunc = function(elem){ \/\/init var cnt = 0; var init = function (){ setInterval(function(){ $(elem).text(cnt); cnt++; if (settings.timerFunc != null){ settings.timerFunc(elem, cnt, settings.interval); } } ,settings.interval); $(elem).click(function(){ cnt = 0; }); }; init(); }; [\/js] \u3053\u308c\u306f\u3001\u4f55\u3082\u8907\u96d1\u306b\u8003\u3048\u308b\u5fc5\u8981\u3082\u306a\u3044\u3001\u30b7\u30f3\u30d7\u30eb\u306a JavaScript\u306e\u95a2\u6570\u3067\u3059\u3002\u5f15\u6570\u306felem\u3067\u3059\u3002 \u95a2\u6570\u306e\u5148\u982d\u3067 cnt\u3068\u3044\u3046\u6570\u5024\u578b\u306e\u5909\u6570\u3092\u5ba3\u8a00\u3057\u3001\uff10\u3067\u521d\u671f\u5316\u3057\u307e\u3059\u3002 \u6b21\u306b\u3000\u5185\u90e8\u95a2\u6570 init \u3092\u547c\u3073\u51fa\u3057\u307e\u3059\u3002 init\u95a2\u6570\u306f setInterval\u3067\u30bf\u30a4\u30de\u30fc\u51e6\u7406\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002\u30bf\u30a4\u30de\u30fc\u306e\u5b9f\u884c\u9593\u9694\u306f\u3001 settings.interval\u3067\u3059\u3002\u5b9f\u884c\u3059\u308b\u4e2d\u8eab\u306f\u3001\u5f15\u6570\u3067\u4e0e\u3048\u3089\u308c\u305f DOM\u30a8\u30ec\u30e1\u30f3\u30c8\u306eText\u306b\u5909\u6570 cnt\u3092\u30bb\u30c3\u30c8\u3059\u308b\u3068\u3044\u3046\u3001\u81f3\u3063\u3066\u30b7\u30f3\u30d7\u30eb\u306a\u4f5c\u308a\u3067\u3059\u3002\u305d\u3057\u3066Text\u306e\u5024\u3092\u5909\u66f4\u3057\u305f\u5f8c\u306b cnt\u5909\u6570\u3092\u30ab\u30a6\u30f3\u30c8\u30a2\u30c3\u30d7\u3057\u307e\u3059\u3002\u305d\u3057\u3066\u3000settings.timerFunc\u3068\u3044\u3046\u5909\u6570\u304cnull\u3067\u306a\u3051\u308c\u3070\u3001settings.timerFunc\u3092\u5b9f\u884c\u3059\u308b\u3002\u6700\u5f8c\u306b\u3082\u3057 elem\u304c\u30af\u30ea\u30c3\u30af\u3055\u308c\u305f\u3089\u3001cnt\u3092\uff10\u306b\u623b\u3059\u3068\u3044\u3046\u51e6\u7406\u304c\u8a18\u8ff0\u3055\u308c\u3066\u3044\u307e\u3059\u3002 \u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u5f15\u6570 \u3055\u3066\u3001\u95a2\u6570\u306e\u5185\u90e8\u3067 settings\u3068\u51fa\u3066\u304d\u307e\u3057\u305f\u304c\u3001\u3053\u308c\u306f\u4f55\u8005\u3067\u3057\u3087\u3046\u304b\uff1f\u3053\u308c\u306f\u3001simpleTimer\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3073\u51fa\u3059\u3068\u304d\u306b\u6307\u5b9a\u3057\u305f\u30aa\u30d7\u30b7\u30e7\u30f3\u5f15\u6570\u306e\u4e2d\u8eab\u3068\u306a\u308a\u307e\u3059\u3002\u5177\u4f53\u7684\u306a\u30bd\u30fc\u30b9\u3067\u3044\u3046\u3068\u4ee5\u4e0b\u306e\u90e8\u5206\u306b\u306a\u308a\u307e\u3059\u3002 [js] $.fn.simpleTimer = function(options){ var target = this; var defaults = { interval : 1000, timerFunc: null };&#8230;<\/p>\n","protected":false},"author":1,"featured_media":388,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[7],"tags":[28,20,21],"class_list":{"0":"post-243","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-jquery","8":"tag-javascript-2","9":"tag-jquery-2","10":"tag-plugin"},"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/posts\/243","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=243"}],"version-history":[{"count":22,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/posts\/243\/revisions"}],"predecessor-version":[{"id":598,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/posts\/243\/revisions\/598"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/media\/388"}],"wp:attachment":[{"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=243"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=243"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=243"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}