나는이 HTML을 가지고 있습니다. 내가 이런 식으로다른 섹션에있는 버튼을 제거하는 방법
var locationname = 'SoftSol';
$("#restmenu").find('section').not("#"+locationname).find('.addNewRestaurant').remove();
그러나 그 버튼을 제거하지 시도
<div id="restmenu" class="restMenu">
<ul>
<section id="LocationX" class="ulseWrap lielement">
<div class="intit">LocationX<span class="inDelete"></span></div>
<ul class="restListings">
<div class="inner-intit">
<sub class="sub">Your Favorite Restaurant</sub><br>
<li>
<h6>Swaghat</h6>
<p>MadhaPur , Near Policstation,Hyderabad</p>
<span class="inDelete inDeleteSub"></span>
</li>
</div>
<input type="button" location="LocationX" name="btn1" class="btn btn-success addNewRestaurant" value="LocationX">
</ul>
</section>
<section id="SoftSol" class="ulseWrap lielement">
<div class="intit">SoftSol<span class="inDelete"></span></div>
<ul class="restListings"><input type="button" location="LocationX" name="btn1" class="btn btn-success addNewRestaurant" value="LocationX"></ul>
</section>
</ul>
</div>
나는 SoftSol 위치에 버튼 선물을 제거해야합니다.
누구든지 내게 무슨 문제인지 알려 주실 수 있습니까?
난 여전히 문제가 있습니다 것은, 내가
이것은 SoftSol
의 버튼 선물을 제거하려면 내 코드
function showRestaurantDetailsByLocation(responseeee,locationname)
{
var ulhtml = $('<ul class="restListings"></ul>');
var divhtml = $('<div class="inner-intit"><sub class="sub">Your Favorite Restaurant</sub></div>');
divhtml.append('<br>');
for(var i=0;i<responseeee.length;i++)
{
divhtml.append('<li><h6>'+responseeee[i].name+'</h6><p>'+responseeee[i].address+'</p><span class="inDelete inDeleteSub"></span></li>');
}
ulhtml.append(divhtml);
$('.restListings').empty();
$("#"+locationname).append(ulhtml);
$("#restmenu").not("#"+locationname).find('.addNewRestaurant').remove();
var $newbutton= $('<input/>').attr({ type: 'button', location:locationname , name:'btn1', class:'btn btn-success addNewRestaurant',value:locationname});
$('.restListings').append($newbutton);
$(".restListings").show();
$("#restmenu").show();
}
가 작동하는 것 같군 dom이로드되기 전에이 코드를 실행하십시오. – smerny
당신도 SoftSol에서 버튼을 제거하길 원한다는 언급을 보았지만, Softsol에서 버튼을 제외한 모든 것을 제거하려고하는 것처럼 보입니다. SoftSol에서 버튼을 제거하려면, 왜 단지'$ ("# "+ locationname) .find (". addNewRestaurant "). remove();'? – smerny
올바르게 작동하고 있습니다. 다른 문제가 있습니다. – afzalex