这是我的HTML页面。
我试图隐藏 myordersdiv
下的 Topping-details 类我是这样尝试的,但是没有隐藏它可以请任何人帮忙。
$("#myordersdiv .Topping-details").hide();
<div id="myordersdiv" style="display: block;">
<ul>
<li class="myorderhead active">
<h5>
My Orders
<i class="myorderhead22">1</i>
</h5>
</li>
<div id="ordersdiv">
<div id="addtoordersdiv69">
<div style="" class="Topping-details" id="69">
<section id="topping_tsection_69">
<i id="topping-close"></i>
<aside>
<h6 class="tdHeading">Quantity 1</h6>
<img src="images/arrow-topping.png">
<section class="secclass"><a data-id="69" class="tpActive">Honey with Carmel 10 ML</a></section>
<section class="secclass"><a data-id="69" class="tpActive">Honey with Carmel 10 ML</a></section>
</aside>
</section>
</div>
</div>
<div class="confirmorder-row">
<a id="ordersconfirm" hrer="#" class="btn btn-confirmorder">confirm order</a>
</div>
</div>
</ul>
</div>
答案 0 :(得分:0)
尝试将您的代码放入DOM-Ready事件
$(function(){
$("#myordersdiv .Topping-details").hide();
}
答案 1 :(得分:0)
你在找这个 -
$(function(){
$("#myordersdiv .Topping-details").each(function(){
var divId = $(this).attr('id'); // Here is your div id with class .Topping-details
$("#"+divId).hide();
});
});
在HERE
中试试答案 2 :(得分:0)
This seems to work.
<div id="myordersdiv">
<ul>
<li class="myorderhead active">
<h5>
My Orders
<i class="myorderhead22">1</i>
</h5>
</li>
<div id="ordersdiv">
<div id="addtoordersdiv69">
<div style="" id="Toppings" id="69">
<section id="topping_tsection_69">
<i id="topping-close"></i>
<aside>
<h6 class="tdHeading">Quantity 1</h6>
<img src="images/arrow-topping.png">
<section class="secclass"><a data-id="69" class="tpActive">Honey with Carmel 10 ML</a></section>
<section class="secclass"><a data-id="69" class="tpActive">Honey with Carmel 10 ML</a></section>
</aside>
</section>
</div>
</div>
<div class="confirmorder-row">
<a id="ordersconfirm" hrer="#" class="btn btn-confirmorder">confirm order</a>
</div>
</div>
</ul>
</div>
$( “#浇头”)隐藏();