gpt4 book ai didi

javascript - Jquery 显示/隐藏更多数据

转载 作者:太空宇宙 更新时间:2023-11-04 09:35:10 25 4
gpt4 key购买 nike

我正在列出 div。我通过 css 将可见 div 限制为 4。我在每个 div 中放置了一个跨度。如果我单击跨度,它会删除限制,并且所有 div 都可见。

我怎样才能做到这一点,当我点击一次 span 时,它只会显示那些与我点击的 span 相近的 div?

抱歉英语不好。

$(".mutat").click(function(){
$(".filter_div").removeClass('filter_div');
$(".mutat").hide();
});

CSS

.mutat{ 
font:bold 13px Arial, Helvetica, sans-serif;
margin-left:8px; display:block;
margin-bottom:15px;
cursor:pointer;
color:#024385;
}
.filter_div:nth-of-type(n+5) {
display: none;
}
.filter_div .mutat {
display: inline;
}

HTML:

<form name="szures_form" method="post">
<div class="sidebar_div sidebar_price_szuro"> <span class="sidebar_contact_span">Árkategória</span>
<input id="range_03" value="" name="" >
<input name="price_from" id="price_from" type="hidden" value="19790">
<input name="price_to" id="price_to" type="hidden" value="172990">
<div class="text-center">
<button type="submit" name="" class="btn szures_btn szures_btn_margin_top">Mehet</button>
</div>
</div>
<div class="sidebar_szuro_div"> <span class="sidebar_contact_span">Gyártó</span>
<div class="checkbox padding_left_10">
<label>
<input type="checkbox" name="gyartok[]" value="8">
Asus</label>
</div>
<div class="checkbox padding_left_10">
<label>
<input type="checkbox" name="gyartok[]" value="10">
Gigabyte</label>
</div>
<div class="checkbox padding_left_10">
<label>
<input type="checkbox" name="gyartok[]" value="9">
MSI</label>
</div>
<div class="text-center">
<button type="submit" name="" class="btn szures_btn">Mehet</button>
</div>
</div>
<div class="sidebar_szurok_box">
<div class="sidebar_szuro_div"><span class="sidebar_contact_span">DirectX verzió</span>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[5][]" value="10.2">
DX 10.2 </label>
</div>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[5][]" value="11">
DX 11 </label>
</div>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[5][]" value="11.2">
DX 11.2 </label>
</div>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[5][]" value="12">
DX 12 </label>
</div>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[5][]" value="12">
DX 12 </label>
</div>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[5][]" value="12">
DX 12 </label>
</div>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[5][]" value="12.1">
DX 12.1 </label>
</div>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[5][]" value="9">
DX 9 </label>
</div>
<span class="mutat">Továbbiak mutatása</span>
<div class="text-center">
<button type="submit" name="" class="btn szures_btn">Mehet</button>
</div>
</div>
<div class="sidebar_szuro_div"><span class="sidebar_contact_span">GPU órajele</span>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[6][]" value="1059">
1059 Mhz</label>
</div>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[6][]" value="1180">
1180 Mhz</label>
</div>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[6][]" value="1735">
1735 Mhz</label>
</div>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[6][]" value="1745">
1745 Mhz</label>
</div>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[6][]" value="1784">
1784 Mhz</label>
</div>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[6][]" value="1790">
1790 Mhz</label>
</div>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[6][]" value="1990">
1990 Mhz</label>
</div>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[6][]" value="790">
790 Mhz</label>
</div>
<span class="mutat">Továbbiak mutatása</span>
<div class="text-center">
<button type="submit" name="" class="btn szures_btn">Mehet</button>
</div>
</div>
<div class="sidebar_szuro_div"><span class="sidebar_contact_span">Grafikus memória mérete</span>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[4][]" value="1">
1 GB</label>
</div>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[4][]" value="10">
10 GB</label>
</div>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[4][]" value="10">
10 GB</label>
</div>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[4][]" value="2">
2 GB</label>
</div>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[4][]" value="3">
3 GB</label>
</div>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[4][]" value="4">
4 GB</label>
</div>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[4][]" value="5">
5 GB</label>
</div>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[4][]" value="8">
8 GB</label>
</div>
<span class="mutat">Továbbiak mutatása</span>
<div class="text-center">
<button type="submit" name="" class="btn szures_btn">Mehet</button>
</div>
</div>
</div>
</form>

最佳答案

使用

  $(".mutat").click(function() {
$(this).hide() // hide the clicked link
.closest('.sidebar_szuro_div').find(".filter_div") // find the .filter_div only under the same .sidebar_szuro_div
.removeClass('filter_div'); //remove class on them
});

$(function() {
$(".mutat").click(function() {
$(this).hide()
.closest('.sidebar_szuro_div').find(".filter_div")
.removeClass('filter_div');

});
})
.mutat {
font: bold 13px Arial, Helvetica, sans-serif;
margin-left: 8px;
display: block;
margin-bottom: 15px;
cursor: pointer;
color: #024385;
}
.filter_div:nth-of-type(n+5) {
display: none;
}
.filter_div .mutat {
display: inline;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<form name="szures_form" method="post">
<div class="sidebar_div sidebar_price_szuro"> <span class="sidebar_contact_span">Árkategória</span>
<input id="range_03" value="" name="">
<input name="price_from" id="price_from" type="hidden" value="19790">
<input name="price_to" id="price_to" type="hidden" value="172990">
<div class="text-center">
<button type="submit" name="" class="btn szures_btn szures_btn_margin_top">Mehet</button>
</div>
</div>
<div class="sidebar_szuro_div"> <span class="sidebar_contact_span">Gyártó</span>
<div class="checkbox padding_left_10">
<label>
<input type="checkbox" name="gyartok[]" value="8">Asus
</label>
</div>
<div class="checkbox padding_left_10">
<label>
<input type="checkbox" name="gyartok[]" value="10">Gigabyte
</label>
</div>
<div class="checkbox padding_left_10">
<label>
<input type="checkbox" name="gyartok[]" value="9">MSI
</label>
</div>
<div class="text-center">
<button type="submit" name="" class="btn szures_btn">Mehet</button>
</div>
</div>
<div class="sidebar_szurok_box">
<div class="sidebar_szuro_div"><span class="sidebar_contact_span">DirectX verzió</span>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[5][]" value="10.2">DX 10.2</label>
</div>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[5][]" value="11">DX 11</label>
</div>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[5][]" value="11.2">DX 11.2</label>
</div>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[5][]" value="12">DX 12</label>
</div>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[5][]" value="12">DX 12</label>
</div>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[5][]" value="12">DX 12</label>
</div>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[5][]" value="12.1">DX 12.1</label>
</div>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[5][]" value="9">DX 9</label>
</div>
<span class="mutat">Továbbiak mutatása</span>
<div class="text-center">
<button type="submit" name="" class="btn szures_btn">Mehet</button>
</div>
</div>
<div class="sidebar_szuro_div"><span class="sidebar_contact_span">GPU órajele</span>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[6][]" value="1059">1059 Mhz</label>
</div>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[6][]" value="1180">1180 Mhz</label>
</div>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[6][]" value="1735">1735 Mhz</label>
</div>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[6][]" value="1745">1745 Mhz</label>
</div>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[6][]" value="1784">1784 Mhz</label>
</div>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[6][]" value="1790">1790 Mhz</label>
</div>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[6][]" value="1990">1990 Mhz</label>
</div>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[6][]" value="790">790 Mhz</label>
</div>
<span class="mutat">Továbbiak mutatása</span>
<div class="text-center">
<button type="submit" name="" class="btn szures_btn">Mehet</button>
</div>
</div>
<div class="sidebar_szuro_div"><span class="sidebar_contact_span">Grafikus memória mérete</span>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[4][]" value="1">1 GB</label>
</div>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[4][]" value="10">10 GB</label>
</div>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[4][]" value="10">10 GB</label>
</div>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[4][]" value="2">2 GB</label>
</div>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[4][]" value="3">3 GB</label>
</div>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[4][]" value="4">4 GB</label>
</div>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[4][]" value="5">5 GB</label>
</div>
<div class="checkbox padding_left_10 filter_div">
<label>
<input type="checkbox" name="tulajdonsag_ertek[4][]" value="8">8 GB</label>
</div>
<span class="mutat">Továbbiak mutatása</span>
<div class="text-center">
<button type="submit" name="" class="btn szures_btn">Mehet</button>
</div>
</div>
</div>
</form>

关于javascript - Jquery 显示/隐藏更多数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40408160/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com