{"id":242,"date":"2022-02-12T22:39:22","date_gmt":"2022-02-12T13:39:22","guid":{"rendered":"https:\/\/software.satoshis.jp\/?p=242"},"modified":"2022-02-27T02:37:08","modified_gmt":"2022-02-26T17:37:08","slug":"safari%e3%81%afoption%e3%82%bf%e3%82%b0%e3%81%abdisplay-none%e3%82%92%e6%8c%87%e5%ae%9a%e3%81%97%e3%81%a6%e3%82%82%e7%84%a1%e8%a6%96%e3%81%99%e3%82%8b%e3%81%a8%e3%81%8b%e3%81%b2%e3%81%a9%e3%81%99","status":"publish","type":"post","link":"https:\/\/software.satoshis.jp\/?p=242","title":{"rendered":"safari\u3067\u306foption\u30bf\u30b0\u306bdisplay: none\u3092\u6307\u5b9a\u3057\u3066\u3082\u7121\u8996\u3055\u308c\u308b\u3068\u3044\u3046\u3072\u3069\u3059\u304e\u308b\u4ed5\u69d8\u306e\u5bfe\u7b56\u65b9\u6cd5"},"content":{"rendered":"<p>\u3068\u3042\u308b\u6848\u4ef6\u3067\u3001\u30e1\u30fc\u30ab\u30fc\u306e\u30ea\u30b9\u30c8\u3068\u5546\u54c1\u306e\u30ea\u30b9\u30c8\u3092 select &#8211; option \u30bf\u30b0\u3067\u4f5c\u308a\u307e\u3057\u3087\u3046\u7684\u306a\u3053\u3068\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u30e1\u30fc\u30ab\u30fc\u3068\u5546\u54c1\u306f\u30de\u30b9\u30bf\u30fc\u30c6\u30fc\u30d6\u30eb\u306b\u3042\u308b\u306e\u3067\u3001\u305d\u3053\u304b\u3089\u3068\u3063\u3066\u304d\u307e\u3059\u3002<\/p>\n<p>Laravel \u306e blade \u306a\u306e\u3067\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30b3\u30fc\u30c9\u3067\u751f\u6210\u3057\u307e\u3059\u3002<br \/>\noption \u30bf\u30b0\u306b\u306f\u3001class \u3067 maker-n \u307f\u305f\u3044\u306a\u611f\u3058\u3067\u30e1\u30fc\u30ab\u30fc\u306eID\u3092\u6301\u305f\u305b\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n    &lt;select name=&quot;maker&quot; id=&quot;makers&quot; class=&quot;form-control&quot;&gt;\r\n        &lt;option value=&quot;-1&quot;&gt;\u30e1\u30fc\u30ab\u30fc\u3092\u9078\u629e&lt;\/option&gt;\r\n        @foreach($makers as $m)\r\n        &lt;option value=&quot;{{ $m-&gt;id }}&quot;&gt;{{ $m-&gt;name }}&lt;\/option&gt;\r\n        @endforeach\r\n    &lt;\/select&gt;\r\n    &lt;select name=&quot;items&quot; id=&quot;items&quot;&gt;\r\n        &lt;option value=&quot;-1&quot;&gt;\u5546\u54c1\u540d\u3092\u9078\u629e&lt;\/option&gt;\r\n        @foreach($items as $item) \r\n        &lt;option value=&quot;{{ $item-&gt;id }}&quot; class=&quot;maker-{{ $item-&gt;maker_id }}&quot; data-name=&quot;{{ $item-&gt;name }}&quot;&gt;{{ $item-&gt;name }}&lt;\/option&gt;\r\n        @endforeach\r\n    &lt;\/select&gt;\r\n<\/pre>\n<p>\u30e1\u30fc\u30ab\u30fc\u3092\u9078\u629e\u3057\u305f\u3089\u3001\u9078\u629e\u3055\u308c\u305f\u30e1\u30fc\u30ab\u30fc\u4ee5\u5916\u306e\u5546\u54c1\u306f\u975e\u8868\u793a\u306b\u3057\u305f\u3044\u306e\u3067\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30b3\u30fc\u30c9\u3092\u66f8\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n$(function() {\r\n    $('#makers').on('change', function() {\r\n        selectionChanged();\r\n    });\r\n});\r\n\r\nfunction selectionChanged() {\r\n    let options = $('#items').children();\r\n    let makerId = $('#makers').val();\r\n    for (let i = 0; i &lt; options.length; i++) {\r\n        if (isMatched(makerId, $(options&#x5B;i]))) {\r\n            $(options&#x5B;i]).show();\r\n        } else {\r\n            $(options&#x5B;i]).hide();\r\n        }\r\n    }\r\n}\r\n\r\nfunction isMatched(mid, e) {\r\n    if (mid &lt; 0) return true;\r\n    if (mid &gt; 0) {\r\n        return e.hasClass('maker-' + mid);\r\n    }\r\n    return e.hasClass('maker-' + mid);\r\n}\r\n<\/pre>\n<p>Chrome \u3068 Firefox \u3068 Edge \u306f\u3053\u308c\u3067\u671f\u5f85\u901a\u308a\u306b\u52d5\u4f5c\u3057\u3066\u304f\u308c\u307e\u3059\u3002<\/p>\n<p>\u304c\u3001safari \u306f\u3059\u3079\u3066\u306e option \u3092\u8868\u793a\u3057\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<p>\u3050\u3050\u3063\u3066\u307f\u308b\u3068\u3001safari \u3060\u3051\u304c\u305d\u3046\u3044\u3046\u6319\u52d5\u3092\u3059\u308b\u307f\u305f\u3044\u3067\u3059\u3002<\/p>\n<p>\u3067\u3001\u89e3\u6c7a\u7b56\u306f\u3069\u3046\u3059\u308c\u3070\u3044\u3044\u306e\u304b\u3068\u3044\u3046\u3068\u3001option \u3092 span \u3067\u56f2\u3093\u3067 span \u306b display: none \u3092\u6307\u5b9a\u3059\u308c\u3070\u3044\u3044\u3068\u304b\u306a\u3093\u3068\u304b\u3002<\/p>\n<p>option \u3092 span \u306e\u4e2d\u306b\u5165\u308c\u308c\u3070\u3044\u3044\u306e\u304b\u3068\u601d\u3063\u3066\u3001blade\u3092\u4fee\u6b63\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n    &lt;select name=&quot;items&quot; id=&quot;items&quot;&gt;\r\n        &lt;option value=&quot;-1&quot;&gt;\u5546\u54c1\u540d\u3092\u9078\u629e&lt;\/option&gt;\r\n        @foreach($items as $item) \r\n        &lt;span&gt;\r\n        &lt;option value=&quot;{{ $item-&gt;id }}&quot; class=&quot;maker-{{ $item-&gt;maker_id }}&quot; data-name=&quot;{{ $item-&gt;name }}&quot;&gt;{{ $item-&gt;name }}&lt;\/option&gt;\r\n        &lt;\/span&gt;\r\n        @endforeach\r\n    &lt;\/select&gt;\r\n<\/pre>\n<p>\u3053\u308c\u3067\u52d5\u304b\u3057\u3066\u307f\u305f\u3093\u3067\u3059\u304c\u3001\u3053\u306e\u30bd\u30fc\u30b9\u3067\u5b9f\u884c\u3057\u3066\u307f\u305f\u3068\u304d\u3001\u958b\u767a\u8005\u30c4\u30fc\u30eb\u3067\u78ba\u8a8d\u3059\u308b\u3068\u3001\u5b8c\u5168\u306b select \u5185\u306e\u3000span \u304c\u7121\u8996\u3055\u308c\u3066\u307e\u3059\u3002<br \/>\nselect \u306e\u76f4\u4e0b\u306b option \u304c\u3042\u308a\u3001 span \u306e\u30bf\u30b0\u306f\u6d88\u6ec5\u3057\u3066\u307e\u3059\u3002<br \/>\n\u3067\u3082\u3001JavaScript\u30b3\u30f3\u30bd\u30fc\u30eb\u304b\u3089\u3000<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n$('option').eq(1).wrap('&lt;span&gt;');\r\n<\/pre>\n<p>\u3068\u3044\u3046\u64cd\u4f5c\u3092\u3059\u308b\u3068\u3001option \u304c span \u30bf\u30b0\u5185\u306b\u5165\u308a\u307e\u3059\u3002<\/p>\n<p>JavaScript\u30b3\u30f3\u30bd\u30fc\u30eb\u3067\u3000$(&#8216;option&#8217;).wrap(&#8216;<span>&#8216;);\u3068\u304b\u3059\u308b\u3068 option \u304c\u3000span \u306b\u56f2\u307e\u308c\u308b\u306e\u3067\u3001\u52d5\u7684\u306b\u306f\u53ef\u80fd\u3060\u3051\u3069\u9759\u7684\u306b\u306f\u7121\u8996\u3055\u308c\u308b\u3063\u307d\u3044\u611f\u3058\u306a\u306e\u304c\u308f\u304b\u308a\u307e\u3059\u3002<\/p>\n<p>\u30d6\u30e9\u30a6\u30b6\u4f9d\u5b58\u306a\u306e\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<\/p>\n<p>option \u3092 span \u306e\u5185\u5074\u306b\u5165\u308c\u308b\u306e\u306f\u3001blade \u3067\u306f\u3067\u304d\u306a\u3055\u305d\u3046\u306a\u306e\u3067\u8ae6\u3081\u307e\u3059\u3002<\/p>\n<p>\u3068\u3044\u3046\u308f\u3051\u3067\u3001\u6b21\u306e\u30a2\u30d7\u30ed\u30fc\u30c1\u3068\u3057\u3066\u3001\u5225\u306e\u5834\u6240\u306b option \u3092\u7528\u610f\u3057\u3066\u304a\u3044\u3066\u3001\u305d\u308c\u3092\u6761\u4ef6\u306b\u5f93\u3063\u3066 select \u306e\u4e2d\u3092\u524a\u9664\u3057\u3066\u3001\u6761\u4ef6\u306b\u3042\u3063\u305f\u3082\u306e\u3060\u3051\u3092\u8ffd\u52a0\u3059\u308b\u65b9\u5411\u3067\u8003\u3048\u3066\u307f\u307e\u3059\u3002<\/p>\n<p>\u307e\u305a\u3001\u5168\u90e8\u306e\u30ea\u30b9\u30c8\u3092\u6301\u3064\u3001\u898b\u3048\u306a\u3044\u8981\u7d20\u3092\u7528\u610f\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;div id=&quot;model-source&quot; style=&quot;display: none;&quot;&gt;\r\n    &lt;select name=&quot;&quot; id=&quot;model-options&quot;&gt;\r\n        &lt;option value=&quot;-1&quot;&gt;\u5546\u54c1\u540d\u3092\u9078\u629e&lt;\/option&gt;\r\n        @foreach($models as $m) \r\n        &lt;option value=&quot;{{ $m-&gt;id }}&quot; class=&quot;maker-{{ $m-&gt;maker_id}} type-{{ $m-&gt;category }}&quot;\r\n            data-name=&quot;{{ $m-&gt;name }}&quot; data-kana=&quot;{{ $m-&gt;name_kana }}&quot;\r\n            data-type=&quot;{{ $m-&gt;type-&gt;name }}&quot; data-chance=&quot;{{ $m-&gt;chance }}&quot;&gt;{{ $m-&gt;name }}&lt;\/option&gt;\r\n        @endforeach\r\n    &lt;\/select&gt;\r\n&lt;\/div&gt;\r\n<\/pre>\n<p>\u3067\u3001\u30e1\u30fc\u30ab\u30fc\u304c\u9078\u629e\u3055\u308c\u305f\u3089\u3001\u305d\u306e\u30e1\u30fc\u30ab\u30fc\u306e\u5546\u54c1\u306b\u5bfe\u5fdc\u3059\u308b option \u3060\u3051\u3092\u5b9f\u969b\u306b\u898b\u3048\u3066\u3044\u308b select \u306b\u8ffd\u52a0\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nfunction selectionChanged() {\r\n    let mid = $('#makers').val();\r\n    let cid = $('#types').val();\r\n    let models = $('#model-source').clone();\r\n    $(models).prop('id', 'cloned');\r\n    let opts = $(models).children();\r\n    let reset = false;\r\n    $('#models').empty();\r\n    $('#models').append($(opts&#x5B;0]));\r\n    for (let i = 1; i &lt; opts.length; i++) {\r\n        if (isMatched(mid, cid, $(opts&#x5B;i]))) {\r\n            $('#models').append($(opts&#x5B;i]));\r\n        }\r\n    }\r\n}\r\n<\/pre>\n<p>\u3042\u3001\u300clet models = $(&#8216;#model-source&#8217;).clone();\u300d\u306e\u6b21\u306b\u300c$(models).prop(&#8216;id&#8217;, &#8216;cloned&#8217;);\u300d\u3057\u3066\u308b\u306e\u306f\u3001\u540c\u4e00id\u306e\u8981\u7d20\u3092\u306a\u304f\u3059\u305f\u3081\u3067\u3059\u3002<br \/>\n\u3057\u306a\u304f\u3066\u3082\u5927\u4e08\u592b\u305d\u3046\u3067\u3059\u304c\u3001\u5ff5\u306e\u305f\u3081\u3002<\/p>\n<p>\u3053\u308c\u3067\u7121\u4e8b\u306b\u671f\u5f85\u901a\u308a\u306e\u52d5\u4f5c\u3092\u3059\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3068\u3042\u308b\u6848\u4ef6\u3067\u3001\u30e1\u30fc\u30ab\u30fc\u306e\u30ea\u30b9\u30c8\u3068\u5546\u54c1\u306e\u30ea\u30b9\u30c8\u3092 select &#8211; option \u30bf\u30b0\u3067\u4f5c\u308a\u307e\u3057\u3087\u3046\u7684\u306a\u3053\u3068\u306b\u306a\u308a\u307e\u3057\u305f\u3002 \u30e1\u30fc\u30ab\u30fc\u3068\u5546\u54c1\u306f\u30de\u30b9\u30bf\u30fc\u30c6\u30fc\u30d6\u30eb\u306b\u3042\u308b\u306e\u3067\u3001\u305d\u3053\u304b\u3089\u3068\u3063\u3066\u304d\u307e\u3059\u3002 &#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[85,3],"tags":[91,89,90,88],"class_list":["post-242","post","type-post","status-publish","format-standard","hentry","category-jquery","category-laravel","tag-display-none","tag-option","tag-safari","tag-select"],"nelio_content":{"autoShareEndMode":"never","automationSources":{"useCustomSentences":false,"customSentences":[]},"efiAlt":"","efiUrl":"","followers":[1],"highlights":[],"isAutoShareEnabled":true,"networkImageIds":[],"permalinkQueryArgs":[],"series":[],"suggestedReferences":[]},"views":11241,"_links":{"self":[{"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts\/242","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=242"}],"version-history":[{"count":5,"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts\/242\/revisions"}],"predecessor-version":[{"id":267,"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts\/242\/revisions\/267"}],"wp:attachment":[{"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=242"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=242"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=242"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}