在按钮 1 的单击事件中,如何仅从本节中删除“选定”类。不应删除 Button 2 的类,对于 Button 2 也是如此,如果我单击按钮 2,如果选择的类存在,则不应删除 Button 1 的类。我知道$('.small-button-1, .small-button-2').removeClass('selected');
删除一切。
<div class="block">
<div id="abcd" class="lg_button">Button 1</div>
<div>
<div class="small-button-1 selected">1</div>
<div class="small-button-2 selected">2</div>
</div>
</div>
<div class="block">
<div id="dcba" class="lg_button">Button 2</div>
<div>
<div class="small-button-1 selected">1</div>
<div class="small-button-2 selected">2</div>
</div>
</div>