{"id":1046,"date":"2017-02-08T12:00:00","date_gmt":"2017-02-08T03:00:00","guid":{"rendered":"https:\/\/hi3103.net\/notes\/?p=1046"},"modified":"2022-07-09T23:33:46","modified_gmt":"2022-07-09T14:33:46","slug":"incboxfilter_select-js","status":"publish","type":"post","link":"https:\/\/hi3103.net\/notes\/web\/1046","title":{"rendered":"incboxfilter_select.js"},"content":{"rendered":"<h4>\u6982\u8981<\/h4>\n<p><a href=\"https:\/\/hi3103.net\/notes\/web\/1036\">\u8aad\u307f\u8fbc\u3093\u3060inc\u30d5\u30a1\u30a4\u30eb\u306e\u8981\u7d20\u3092\u7d5e\u8fbc\u8868\u793a\u3059\u308bjQuery &#8211; incboxfilter.js<\/a>\u3092\u30d7\u30eb\u30c0\u30a6\u30f3\u30bb\u30ec\u30af\u30bf\u30fc\u306b\u3057\u305f\u30d0\u30fc\u30b8\u30e7\u30f3\u3002<br \/>\n\u30b9\u30bf\u30a4\u30eb\u3082\u30b7\u30f3\u30d7\u30eb\u306b\u3057\u305f\u3002<\/p>\n<h4>\u6210\u679c\u7269<\/h4>\n<p>http:\/\/hi3103.net\/study\/incboxfilter_select\/<\/p>\n<h5>HTML<\/h5>\n<pre><code class=\"language-html\">&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n&lt;head&gt;\n    &lt;meta charset=\"UTF-8\"&gt;\n    &lt;link rel=\"stylesheet\" type=\"text\/css\" href=\"css\/style.css\"&gt;\n    &lt;script src=\"https:\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/3.1.1\/jquery.min.js\"&gt;&lt;\/script&gt;\n    &lt;script src=\"js\/incboxfilter_select.js\" charset=\"UTF-8\"&gt;&lt;\/script&gt;\n    &lt;title&gt;incboxfilter_select.js&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n\n    &lt;select name=\"filter\"&gt;\n        &lt;option value=\"all\" selected=\"selected\"&gt;Show All&lt;\/option&gt;\n        &lt;option value=\"green\"&gt;Show Green Boxes&lt;\/option&gt;\n        &lt;option value=\"blue\"&gt;Show Blue Boxes&lt;\/option&gt;\n        &lt;option value=\"red\"&gt;Show Red Boxes&lt;\/option&gt;\n        &lt;option value=\"hoge\"&gt;Show Hoge Boxes&lt;\/option&gt;\n    &lt;\/select&gt;\n\n    &lt;div class=\"boxes\"&gt;&lt;\/div&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n<h5>incboxfilter_select.js<\/h5>\n<pre><code class=\"language-javascript\">$(function(){\n    $('.boxes').load('inc\/box.inc', null, function() {\n        var $filters = $('select[name=filter]');\n        var $boxes = $('.boxes a');\n\n        $filters.change(function () {\n            $('select option:selected').each(function () {\n                var $filterColor = $(this).attr('value');\n\n                if ($filterColor == 'all') {\n                    $boxes.fadeOut().promise().done(function() {\n                        $boxes.fadeIn();\n                    });\n                } else {\n                    $boxes.fadeOut().promise().done(function() {\n                        $boxes.filter('.'+$filterColor).fadeIn();\n                    });\n                }\n            });\n        });\n    });\n});<\/code><\/pre>\n<h5>box.inc<\/h5>\n<pre><code class=\"language-html\">&lt;a class=\"red\" href=\"#\"&gt;Box1&lt;\/a&gt;\n&lt;a class=\"green\" href=\"#\"&gt;Box2&lt;\/a&gt;\n&lt;a class=\"blue hoge\" href=\"#\"&gt;Box3&lt;\/a&gt;\n&lt;a class=\"green\" href=\"#\"&gt;Box4&lt;\/a&gt;\n&lt;a class=\"red\" href=\"#\"&gt;Box5&lt;\/a&gt;\n&lt;a class=\"green\" href=\"#\"&gt;Box6&lt;\/a&gt;\n&lt;a class=\"blue\" href=\"#\"&gt;Box7&lt;\/a&gt;\n&lt;a class=\"red hoge\" href=\"#\"&gt;Box8&lt;\/a&gt;\n&lt;a class=\"green\" href=\"#\"&gt;Box9&lt;\/a&gt;\n&lt;a class=\"blue\" href=\"#\"&gt;Box10&lt;\/a&gt;\n&lt;a class=\"red\" href=\"#\"&gt;Box11&lt;\/a&gt;\n&lt;a class=\"green hoge\" href=\"#\"&gt;Box12&lt;\/a&gt;\n&lt;a class=\"blue hoge\" href=\"#\"&gt;Box13&lt;\/a&gt;\n&lt;a class=\"green\" href=\"#\"&gt;Box14&lt;\/a&gt;\n&lt;a class=\"red\" href=\"#\"&gt;Box15&lt;\/a&gt;\n&lt;a class=\"blue\" href=\"#\"&gt;Box16&lt;\/a&gt;<\/code><\/pre>\n<h5>style.css<\/h5>\n<pre><code class=\"language-css\">@charset \"UTF-8\";\n\na {\n    display: inline-block;\n    text-decoration: none;\n    text-align: center;\n    margin-bottom: 1em;\n    margin-right: 1em;\n}\n\n.boxes a {\n    width: 10em;\n    color:#FFF;\n}\n\n.green{\n    background: lightgreen;\n}\n.blue{\n    background: lightblue;\n}\n.red{\n    background: lightcoral;\n}\n.hoge{\n    border: 2px solid #000;\n}<\/code><\/pre>\n<h4>\u53c2\u8003URL<\/h4>\n<ul>\n<li><a href=\"http:\/\/semooh.jp\/jquery\/api\/events\/change\/fn\/\">change(fn) &#8211; jQuery \u65e5\u672c\u8a9e\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u8981 \u8aad\u307f\u8fbc\u3093\u3060inc\u30d5\u30a1\u30a4\u30eb\u306e\u8981\u7d20\u3092\u7d5e\u8fbc\u8868\u793a\u3059\u308bjQuery &#8211; incboxfilter.js\u3092\u30d7\u30eb\u30c0\u30a6\u30f3\u30bb\u30ec\u30af\u30bf\u30fc\u306b\u3057\u305f\u30d0\u30fc\u30b8\u30e7\u30f3\u3002 \u30b9\u30bf\u30a4\u30eb\u3082\u30b7\u30f3\u30d7\u30eb\u306b\u3057\u305f\u3002 \u6210\u679c\u7269 http:\/\/hi3103.ne [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[53],"tags":[45,44,46],"class_list":["post-1046","post","type-post","status-publish","format-standard","hentry","category-web","tag-javascript","tag-jquery","tag-product"],"_links":{"self":[{"href":"https:\/\/hi3103.net\/notes\/wp-json\/wp\/v2\/posts\/1046","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hi3103.net\/notes\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hi3103.net\/notes\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hi3103.net\/notes\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hi3103.net\/notes\/wp-json\/wp\/v2\/comments?post=1046"}],"version-history":[{"count":0,"href":"https:\/\/hi3103.net\/notes\/wp-json\/wp\/v2\/posts\/1046\/revisions"}],"wp:attachment":[{"href":"https:\/\/hi3103.net\/notes\/wp-json\/wp\/v2\/media?parent=1046"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hi3103.net\/notes\/wp-json\/wp\/v2\/categories?post=1046"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hi3103.net\/notes\/wp-json\/wp\/v2\/tags?post=1046"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}