我很新,因爲我主要是後端JQuery。所以我有一個是這樣的一個表:如何在JQuery中隱藏相同級別的分區?
<tr>
<td>
<div class="div-package-service"><a style="cursor: pointer" id="service_"+id+" class="package-service"> Service Name </a></div>
<span><br>ANYTIME</span>
<div><br><a style="cursor: pointer" class="remove-button">Remove></a></div>
</td>
的排輩是循環的,因此在服務ID id變量。現在我想隱藏「分區包服務」,我用這jQuery代碼:
var hideSchedule = {
removeServiceSchedule: function (span) {
$(span).siblings().find('div').hide();
}
}
$(document).on('click', '.remove-button', function (e) {
e.preventDefault();
hideSchedule.removeServiceSchedule(this);
});
我嘗試了各種方法,但我還是不明白這一點。我可以在我的系統的其他部分做到這一點,但我不能在這裏做。感謝幫助!
你在這裏有一個問題'id =「service _」+ id +「' –
我沒有看到任何具有class'package-service-remove'的元素。你是否缺少任何HTML? – vijayP
對不起,我忘了添加它。 – passerby