我有以下代码:
<ul>
<li id="1">same html structure as below...</li>
.....
<li id="42">
<div class="input-prepend">
<button class="btn btn-small companyListBtn addMarkerBtn btn-primary btn-warning" type="button"> </button>
<input class="input-medium companyListInput" maxlength="60" type="text"/>
<button class="companyListBtn editCompanyBtn" type="button"></button>
</div>
<div id="42Div" class="companyAddressDiv">
<input type="text" id="test" class="companyAddress" placeholder="Enter the Address"/>
<button class="btn btn-small compAddressSubmit" style="height:30px;margin-top:-9px;" type="button"></button>
</div>
</li>
</ul>
现在在下面的代码中,我试图更改位于同一列表中的addMarkerBtn上的信息.... :(因为有多个具有相同结构的列表)
$(document).on('click','.compAddressSubmit', function () {
var addMarkerBtn = $(this).prev("div.row").find('.addMarkerBtn');
//wanna make changes to the addMarkerButton .. something like..
addMarkerBtn.removeClass('btn-primary btn-warning').addClass('btn-success');
}
尝试了最接近(),下一个(),但无法让它工作。任何帮助请...