我試圖創建一個類似於這個圖像的下拉效果:GIF,但是與我到目前爲止:EXAMPLE我似乎無法找出一種方法來添加多個鏈接,如果我確實添加了另一個內容div,它就不會顯示出來。希望有人能夠幫助,並在這個哈哈上失去睡眠。由於可摺疊的容器/柱子。添加多個鏈接
HTML:
<div class="container">
<div class="header">Projects</div>
<div class="content" onclick="initContent('example')"><em>Example Project</em></div>
</div>
JS:
$(".header").click(function() {
$header = $(this);
//getting the next element
$content = $(this).next();
//checking if its already visible
$content.slideToggle(500, function() {
//execute this after slideToggle is done
//change text of header based on visibility of content div
$header.text(function() {});
});
});
我會嘗試:
<div class="container">
<div class="header">Projects</div>
<div class="content" onclick="initContent('example')"><em>Example Project</em></div>
<div class="content" onclick="initContent('exampleNew')"><em>Example Project 2</em></div>
</div>
https://jsfiddle.net/sfcm95yz/6/在我的代碼下方看到我的代碼 –