这是我的HTML
<div id="restmenu" class="restMenu">
<ul>
<section id="office" class="ulseWrap lielement">
<div class="intit">office<span class="inDelete"></span></div>
<ul class="restListings">
<div class="inner-intit">
<sub class="sub">Your Favorite Restaurant</sub><br>
<li>
<h6>Attapur</h6>
<p>Near Pullareddy sweets, Mehdipatna,</p>
<span class="inDelete inDeleteSub"></span>
</li>
</div>
<input type="button" location="home" name="btn1" class="btn btn-success addNewRestaurant" value="home">
</ul>
</section>
<section id="home" class="ulseWrap lielement">
<div class="intit">home<span class="inDelete"></span></div>
<ul class="restListings">
<div class="inner-intit">
<sub class="sub">Your Favorite Restaurant</sub><br>
<li>
<h6>Nizampet</h6>
<p>Near GRIET, Nizamet</p>
<span class="inDelete inDeleteSub"></span>
</li>
</div>
<input type="button" location="home" name="btn1" class="btn btn-success addNewRestaurant" value="home">
</ul>
</section>
<section id="hostel" class="ulseWrap lielement">
<div class="intit">hostel<span class="inDelete"></span></div>
</section>
</ul>
</div>
我需要从所有部分删除带有类addNewRestaurant的按钮
我尝试了不同的选择,但没有任何效果。
$("#restmenu").find('.addNewRestaurant').remove();
任何人都可以帮助我。
忘了添加
按钮以这种方式创建
var $newbutton= $('<input/>').attr({ type: 'button', location:locationname , name:'btn1', class:'btn btn-success addNewRestaurant', value:locationname});
答案 0 :(得分:2)
如果要删除它,请执行此操作。如果你想隐藏它,请调用hide。要做的主要事情是通过将它包装在$(function() { });
$(function() {
$('#restmenu .addNewRestaurant').remove();
});
我在这里创造了一个小提琴:http://jsfiddle.net/jzd5kxuu/1/