我已获得此css
<a href="#" class="tpActive">Butter Extra - Rs. 25/-</a>
我一直在尝试这种方式
$(document).on("click", ".secclass a", function (e) {
// if(whetherchecked)
// {
var name = $(this).attr("name");
var topping='<div class="Topping-details"><section><a href="#">'+name+'</a></section></div>';
//$( "a" ).addClass( "tpActive" );
//$(this).addClass(background-color: Green!important);
$( this ).addClass( "tpActive" );
$("#myordersdiv").append(topping);
clcik++;
$("#myordersdiv").find("i.myorderhead22").text(clcik);
$("#myordersdiv").show();
//toppings.push(name);
// }
});
但是所选元素没有被该类反映出来? 有人可以帮帮我吗?
这是完整的CSS
<div class="Topping-details">
<img src="images/arrow-topping.png"/>
<section><i id="topping-close"></i>
<a href="#">Ketchup Extra - Rs. 25/-</a>
<a href="#" class="tpActive">Butter Extra - Rs. 25/-</a>
<a href="#">Cheeze Extra - Rs. 25/-</a>
</section>
</div>
答案 0 :(得分:1)
$(document).on("click", ".secclass a", function (e) {
var name = $(this).attr("name");
var topping='<div class="Topping-details"><section><a href="#">'+name+'</a></section></div>';
$( "a" ).each(function(){
$(this).addClass( "tpActive" );
});
});
让我知道它是怎么回事。