点击“商店”点击
后,“商品”点击事件无效<div class="i_find">
<div class="replaced_link">Goods</div>
<div class="link_container"><a href="#" class="a_shops">Shops</a></div>
</div>
答案 0 :(得分:1)
您需要在此处使用事件委派:
$("body").on('click','.a_shops',function(){
$('.i_find div:eq(0)').replaceWith('<div class="link_container"><a class="a_goods" href="#">Goods</a></div>');
$('.i_find div:eq(1)').replaceWith('<div class="replaced_link">Shops</div>');
});
$("body").on('click','.a_goods',function(){
$('.i_find div:eq(0)').replaceWith('<div class="replaced_link">Goods</div>');
$('.i_find div:eq(1)').replaceWith('<div class="link_container"><a class="a_shops" href="#">Shops</a></div>');
});
<强> Working Demo 强>