質問編集履歴
1
教えて下さってありがとうございます! 重複分削除いたしました。
    
        title	
    CHANGED
    
    | 
            File without changes
         | 
    
        body	
    CHANGED
    
    | @@ -1,104 +1,4 @@ | |
| 1 1 | 
             
            ###前提・実現したいこと
         | 
| 2 | 
            -
            jQueryで画像(150枚程)の絞り込み検索(or検索)をするにあたり
         | 
| 3 | 
            -
             | 
| 4 | 
            -
            allのボタンをクリックすると、
         | 
| 5 | 
            -
            ◎ すべての画像を表示して、
         | 
| 6 | 
            -
            ◎ チェックボックスは選択されていない状態にする
         | 
| 7 | 
            -
            (チェックされた時に、cssで色がつくようにしています)
         | 
| 8 | 
            -
            という処理をしたいと思っております。
         | 
| 9 | 
            -
             | 
| 10 | 
            -
            方法がわからず、現在はページをリロードする記述にしていますが、
         | 
| 11 | 
            -
            画像が多いので、できればリロードしない方法を希望しております。
         | 
| 12 | 
            -
             | 
| 13 | 
            -
            何か方法がありましたら、お教え頂きたくよろしくお願い致します。
         | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
            ###該当のソースコード
         | 
| 19 | 
            -
             | 
| 20 | 
            -
            ```html
         | 
| 21 | 
            -
            <input type="button"  value="ALL" onclick="allselect()">
         | 
| 22 | 
            -
            <form>
         | 
| 23 | 
            -
            <div id="select">
         | 
| 24 | 
            -
            <div id="style">
         | 
| 25 | 
            -
            <input type="checkbox" id="shirt"><label class="label" for="shirt">シャツ</label>
         | 
| 26 | 
            -
            <input type="checkbox" id="skirt"><label class="label" for="skirt">スカート</label>
         | 
| 27 | 
            -
            <input type="checkbox" id="another"><label class="label" for="another">その他</label>
         | 
| 28 | 
            -
            </div>
         | 
| 29 | 
            -
            <div id="color">
         | 
| 30 | 
            -
            <input type="checkbox" id="white"><label class="label" for="white">ホワイト</label>
         | 
| 31 | 
            -
            <input type="checkbox" id="pink"><label class="label" for="pink">ピンク</label>
         | 
| 32 | 
            -
            <input type="checkbox" id="purple"><label class="label" for="purple">パープル</label>
         | 
| 33 | 
            -
            </div>            
         | 
| 34 | 
            -
            </div>
         | 
| 35 | 
            -
            </form>
         | 
| 36 | 
            -
            <div class="result">
         | 
| 37 | 
            -
            <section class="skirt white"><img src="image/sample.jpg" ></section>
         | 
| 38 | 
            -
            <section class="shirt pink"><img src="image/sample2.jpg" ></section>
         | 
| 39 | 
            -
            〜
         | 
| 40 | 
            -
            ```
         | 
| 41 | 
            -
             | 
| 42 | 
            -
            ```css
         | 
| 43 | 
            -
            input[type=checkbox] {
         | 
| 44 | 
            -
            	display: none;	
         | 
| 45 | 
            -
            }
         | 
| 46 | 
            -
            #select label{	
         | 
| 47 | 
            -
            	display: block;			
         | 
| 48 | 
            -
            	background-color:#ccc;
         | 
| 49 | 
            -
            	color: #333;			
         | 
| 50 | 
            -
            }
         | 
| 51 | 
            -
            #select input:checked + label {
         | 
| 52 | 
            -
            	color:#fff;
         | 
| 53 | 
            -
            	background-color: #333;	
         | 
| 54 | 
            -
            } 
         | 
| 55 | 
            -
            ```
         | 
| 56 | 
            -
             | 
| 57 | 
            -
            ```javascript
         | 
| 58 | 
            -
            <script>//header内
         | 
| 59 | 
            -
            function allselect(){
         | 
| 60 | 
            -
              location.reload(true)
         | 
| 61 | 
            -
            }
         | 
| 62 | 
            -
            </script>
         | 
| 63 | 
            -
             | 
| 64 | 
            -
            <script>//body内
         | 
| 65 | 
            -
            $(function(){
         | 
| 66 | 
            -
            	$('.result section').show();	
         | 
| 67 | 
            -
            $('#style,#color').find('input').on('click',function(){ 
         | 
| 68 | 
            -
            		$('.result section').hide(); 
         | 
| 69 | 
            -
            		$('#style [type=checkbox]:checked').each(function(){ 	
         | 
| 70 | 
            -
            		var checkstyle=$(this).prop('id'); 
         | 
| 71 | 
            -
            		$('#color [type=checkbox]:checked').each(function(){
         | 
| 72 | 
            -
            		var checkcolor=$(this).prop('id');
         | 
| 73 | 
            -
            		$('.result section').filter(function(){return $(this).hasClass(checkstyle) && $(this).hasClass(checkcolor);}).fadeIn();
         | 
| 74 | 
            -
            	 });
         | 
| 75 | 
            -
            });
         | 
| 76 | 
            -
             | 
| 77 | 
            -
            	if($('#style [type=checkbox]:checked').length==0){
         | 
| 78 | 
            -
            		$('#color [type=checkbox]:checked').each(function(){
         | 
| 79 | 
            -
            		var checkcolor=$(this).prop('id');
         | 
| 80 | 
            -
            		$('.result section').filter(function(){return $(this).hasClass(checkcolor);}).fadeIn();
         | 
| 81 | 
            -
            	});
         | 
| 82 | 
            -
                };
         | 
| 83 | 
            -
                if($('#color [type=checkbox]:checked').length==0){
         | 
| 84 | 
            -
            		$('#style [type=checkbox]:checked').each(function(){
         | 
| 85 | 
            -
            		var checkstyle=$(this).prop('id');
         | 
| 86 | 
            -
            		$('.result section').filter(function(){return $(this).hasClass(checkstyle);}).fadeIn();
         | 
| 87 | 
            -
            	});
         | 
| 88 | 
            -
                };
         | 
| 89 | 
            -
              }).trigger('change');
         | 
| 90 | 
            -
            });
         | 
| 91 | 
            -
            </script>
         | 
| 92 | 
            -
            ```
         | 
| 93 | 
            -
             | 
| 94 | 
            -
             | 
| 95 | 
            -
             | 
| 96 | 
            -
            ###補足情報
         | 
| 97 | 
            -
            絞り込み検索は、
         | 
| 98 | 
            -
            [https://teratail.com/questions/85488]
         | 
| 99 | 
            -
            のご質問とご回答を参考に、少しだけ変更を加えさせていただいたものです。
         | 
| 100 | 
            -
            (ずっとやりたかった検索方法でとても助かりました。ありがとうございました)
         | 
| 101 | 
            -
            ###前提・実現したいこと
         | 
| 102 2 | 
             
            jQueryで画像の絞り込み検索をするにあたり
         | 
| 103 3 |  | 
| 104 4 | 
             
            allのボタンをクリックすると、
         | 
