{"id":286,"date":"2011-10-05T11:09:47","date_gmt":"2011-10-05T02:09:47","guid":{"rendered":"http:\/\/www.whoocus.com\/blog\/wordpress\/?p=286"},"modified":"2011-10-05T11:09:47","modified_gmt":"2011-10-05T02:09:47","slug":"286","status":"publish","type":"post","link":"https:\/\/www.blowfish.co.jp\/?p=286","title":{"rendered":"jQuery Plugin \u4e8b\u59cb\u3081 \u305d\u306e1"},"content":{"rendered":"<p>\u4ee5\u524d\u3082\u8a18\u8ff0\u3057\u305f\u304c\u3001jQuery \u30d7\u30e9\u30b0\u30a4\u30f3\u5f62\u5f0f\u3067\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u8a18\u8ff0\u3059\u308b\u3068\u4e2d\u3005\u826f\u3044\u304b\u3082\u3057\u308c\u306a\u3044\u3002<br \/>\n\u4eca\u5f8c\u306f\u52c9\u5f37\u304c\u3066\u3089\u306b\u3001jQuery \u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u4f5c\u6210\u65b9\u6cd5\u3092\u8a66\u3057\u3066\u3044\u3053\u3046\u3068\u601d\u3046\u3002<br \/>\n\u8a66\u884c\u932f\u8aa4\u3057\u306a\u304c\u3089\u306e\u8a18\u8ff0\u306a\u306e\u3067\u3001\u4f7f\u7528\u65b9\u6cd5\u306b\u9593\u9055\u3044\u7b49\u304c\u3042\u308b\u304b\u3082\u3057\u308c\u306a\u3044\u306e\u3067\u53c2\u8003\u307e\u3067\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<br \/>\n[javascript]<br \/>\n&lt;script<br \/>\nsrc=&quot;https:\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/1.6.4\/jquery.min.js&quot;<br \/>\ntype=&quot;text\/javascript&quot; &gt;&lt;\/script&gt;<br \/>\n&lt;script src=&quot;jquery.myPlugin.js&quot; type=&quot;text\/javascript&quot; &gt;&lt;\/script&gt;<br \/>\n&lt;script type=&quot;text\/javascript&quot;&gt;<br \/>\n$(function(){<\/p>\n<p>    $(&quot;#test&quot;).myPlugin({<br \/>\n        params : [{title : &#8216;optTitle1&#8217;, name: &#8216;optName1&#8217;, id: &#8216;011&#8217;},<br \/>\n                  {title : &#8216;optTitle2&#8217;, name: &#8216;optName2&#8217;, id: &#8216;022&#8217;}<br \/>\n                 ]<br \/>\n    });<\/p>\n<p>});<br \/>\n&lt;\/script&gt;<br \/>\n[\/javascript]<\/p>\n<p>[javascript]<br \/>\n\/*<br \/>\n * jQuery\u30d7\u30e9\u30b0\u30a4\u30f3\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8<br \/>\n *\/<br \/>\n;(function($){<br \/>\n    var target;<br \/>\n    var opts;<br \/>\n    $.fn.myPlugin = function(options){<br \/>\n        \/\/\u5bfe\u8c61\u306e\u30b9\u30b3\u30fc\u30d7\u3092\u8a2d\u5b9a<br \/>\n        target = $(this);<br \/>\n        \/\/\u30aa\u30d7\u30b7\u30e7\u30f3\u53d6\u5f97<br \/>\n        opts = jQuery.extend({}, $.fn.myPlugin.defaults, options);<br \/>\n        \/\/opts = jQuery.extend(true, $.fn.myPlugin.defaults, options);<\/p>\n<p>        return this.each(function(){<br \/>\n            \/\/\u51e6\u7406\u8a18\u8ff0<br \/>\n            func1();<br \/>\n            $(this).css({width : opts.width,<br \/>\n                          height : opts.height,<br \/>\n                          background : opts.color});<br \/>\n        });<br \/>\n    };<br \/>\n    \/\/\u30ed\u30fc\u30ab\u30eb\u95a2\u6570<br \/>\n    function func1(){<br \/>\n        \/\/\u30d1\u30e9\u30e1\u30fc\u30bf\u3082\u53d6\u5f97\u53ef\u80fd<br \/>\n        var targetId = target.attr(&#8216;id&#8217;);<br \/>\n        var param = opts.param;<br \/>\n        var params = opts.params;<\/p>\n<p>console.log(targetId + &quot;\/&quot; + param + &quot;\/&quot;<br \/>\n+ params[0].title + &quot;\/&quot; + params[1].title);<\/p>\n<p>    };<br \/>\n    \/\/\u30c7\u30d5\u30a9\u30eb\u30c8\u5024<br \/>\n    $.fn.myPlugin.defaults = {<br \/>\n        param : &#8216;hoge&#8217;,<br \/>\n        params : [{title : &#8216;defTitle1&#8217;, name: &#8216;defName1&#8217;, id: &#8216;111&#8217; },<br \/>\n                  {title : &#8216;defTitle2&#8217;, name: &#8216;defName2&#8217;, id: &#8216;222&#8217; }<br \/>\n                 ],<br \/>\n        height : &#8216;200px&#8217;,<br \/>\n        width :  &#8216;300px&#8217;,<br \/>\n        color : &#8216;blue&#8217;<br \/>\n    };<br \/>\n})(jQuery);<br \/>\n[\/javascript]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4ee5\u524d\u3082\u8a18\u8ff0\u3057\u305f\u304c\u3001jQuery \u30d7\u30e9\u30b0\u30a4\u30f3\u5f62\u5f0f\u3067\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u8a18\u8ff0\u3059\u308b\u3068\u4e2d\u3005\u826f\u3044\u304b\u3082\u3057\u308c\u306a\u3044\u3002 \u4eca\u5f8c\u306f\u52c9\u5f37\u304c\u3066\u3089\u306b\u3001jQuery \u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u4f5c\u6210\u65b9\u6cd5\u3092\u8a66\u3057\u3066\u3044\u3053\u3046\u3068\u601d\u3046\u3002 \u8a66\u884c\u932f\u8aa4\u3057\u306a\u304c\u3089\u306e\u8a18\u8ff0\u306a\u306e\u3067\u3001\u4f7f\u7528\u65b9\u6cd5\u306b\u9593\u9055\u3044\u7b49 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"saved_in_kubio":false,"footnotes":""},"categories":[10,4],"tags":[],"class_list":["post-286","post","type-post","status-publish","format-standard","hentry","category-javascript","category-tech"],"_links":{"self":[{"href":"https:\/\/www.blowfish.co.jp\/index.php?rest_route=\/wp\/v2\/posts\/286","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.blowfish.co.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.blowfish.co.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.blowfish.co.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.blowfish.co.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=286"}],"version-history":[{"count":0,"href":"https:\/\/www.blowfish.co.jp\/index.php?rest_route=\/wp\/v2\/posts\/286\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.blowfish.co.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=286"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.blowfish.co.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=286"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.blowfish.co.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=286"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}