我有幾個表具有類似的類名,但一次只能看到一個表。我遇到了使用jQuery來檢測和保存可見表的類名的麻煩(我可以使用.is(':visible')來檢查並保存好名字的類名,但它很麻煩)。 。我很欣賞任何建議。jQuery檢測哪個元素是可見的
HTML
<table class="tab_Chemical" border="0" style="display:none">
<tr><th><label for="id_wat_hl">Water Column Half life (days):</label></th>
<td><input type="text" name="wat_hl" id="id_wat_hl" /></td></tr>
</table>
<table class="tab_Physical" border="0">
<tr><th><label for="id_mas_tras_cof">Mass Transfer Coefficient (m/s):</label></th>
<td><input type="text" name="mas_tras_cof" value="1e-08" id="id_mas_tras_cof" /></td></tr>
</table>
JS
<script type="text/javascript">
$(document).ready(function() {
###CODE TO DETECT VISIBLE CLASS and SAVE the CLASS NAME###
});
</script>
你可以直接將'class =「active」'添加到可見的表中嗎?這樣,您可以選擇活動表格。 – adamdehaven 2013-02-27 19:22:55
類選擇vs:by可視僞選擇器不應該有任何不同,只要它是*「有點麻煩」* – 2013-02-27 19:24:40
實際上,這些表的可見性正在改變...... – 2013-02-27 19:24:44