好的,所以我有一個包含單個行或父行的表以及與該父級鏈接的幾個子級。我有圖標可以刪除父親或個人的兒子。圖標將顯示模式彈出(而不是警報)以確認刪除。它有效,但我將不得不重複一遍。我想這可以簡化以找到一個ID或類,因爲模式顯示/隱藏這樣工作。提前致謝。簡化並重寫我的重複代碼
<script>
function delVesselAll(){
$("#vessel_tab #father1").remove();
$("#vessel_tab .son1").remove();
document.getElementById(id).style.display = 'block';
};
function delVesselAll2(){
$("#vessel_tab #father2").remove();
$("#vessel_tab .son2").remove();
document.getElementById(id).style.display = 'block';
};
</script>
而且我的html:
<td class="cell_50">
<a style="text-decoration:none;" onclick="showModal('delAll1')"><img src="images/delete-row-icon1.png" title="Delete this row" height="12" width="12" class="father1Del" id="father1Del"/></a>
</td>
<div class="delModal" style="z-index:999999; margin-left:200px; margin-top:30px; display:none" id="delAll1">
<img src="images/warning.png" /> Are you sure you want to delete vessel and the corresponding tanks?<br />
<input type="button" value="Cancel" class="hide" onclick="hideModal('delAll1')"/>
<input type="button" value="Delete" onclick="delVesselAll()"/>
</div>
所以我基本上是做同樣的事情很多行,可以有類或ID 「father1」 「father2」 「SON1」 「son2」。此外,我想這些div淡入淡出,使用類似$(this).fadeIn('slow');
在此先感謝。
您應該顯示完整的佈局。 '#vessel_tab'和co。在哪裏? – Alexander