Last active
July 5, 2018 03:24
-
-
Save yu-smc/51870365158f37df1915ef72418df8ca to your computer and use it in GitHub Desktop.
複数項目の詳細表示 / 非表示を、JQuery5行で実装する ref: https://qiita.com/yu-smc/items/9bbd57f1e842eda20a18
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.pulldown { | |
width: 300px; | |
margin: 0 0 10px 20px; | |
} | |
.pulldown-head { | |
background-color: lightgreen; | |
height: 40px; | |
} | |
.pulldown-body { | |
display: none; | |
background-color: lightgray; | |
height: 200px; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//data-slideがslide1の要素をクリックした時 | |
$('.' + $(this).data('slide'))==$('slide1') | |
//data-slideがslide2の要素をクリックした時 | |
$('.' + $(this).data('slide'))==$('slide2') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="pulldown-head" data-slide="slide1" data-fade="fade1">ここを押すと表示 / 非表示</div> | |
<div class="pulldown-body slide1"> | |
<p class="fade1">詳細部分をフェードイン / アウト</p> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function(){ | |
$('.pulldown-head').on('click', function(){ | |
$('.' + $(this).data('slide')).slideToggle(700); | |
$('.' + $(this).data('fade')).fadeToggle(700); | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment