[英]Chrome copies entire html despite using “user-select: none” because of neighbor div
[英]Empty the entire neighbor div section
我有兩個div parent
節,當我單擊任一.parent
keywordsubmit
按鈕時,我想清空其鄰居。 但是以下代碼不起作用:
$('.parent').each(function() {
$(.keywordsubmit).click(function(e){
$(this).parent().siblings('#phpcom').empty();
});
});
HTML代碼:
<div>
<div class="parent">
<select>
<option>AAA</option>
</select>
<inputtype="text">
<button type="submit" class="keywordsubmit">Submit</button>
<div class="area"></div>
</div>
<div class="parent">
<select>
<option>AAA</option>
</select>
<inputtype="text">
<button type="submit" class="keywordsubmit">Submit</button>
<div class="area"></div>
</div>
<div id="phpcom">.............</div>
</div>
我也嘗試過closest()
, next()
,但似乎缺少了一些東西。 任何幫助,將不勝感激。
$('.keywordsubmit').click(function(){
$('#phpcom').empty();
});
嘗試這個
$('.keywordsubmit').click(function(){
greatParent = $(this).parents('.parent').parent();
$("#phpcom",greatParent).empty();
});
只要這樣做:
$('.keywordsubmit').click(function(){
$(this).closest('.parent').next().empty();
});
試試下面的代碼,它可能對您有幫助
$('.parent').each(function() {
$(.keywordsubmit).click(function(e){
$('.parent').hide();
$(this).parent().show();
});
});
使用此JSFIDDLE
$('.keywordsubmit').click(function(){
$('.parent').hide();
$(this).parent().show();
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.