我已經拼湊出一個簡單的函數,它可以調整某些徽標的高度,因爲它們在高度上顯得太大。代碼在我第一次測試時工作得很好。但是現在它只能在每第3次點擊第4次點擊時才起作用。我懷疑它與文檔加載功能與圖像加載有關,但我不確定。關於文檔加載事件的Jquery偶爾會觸發
<script>
// Get on screen image
$(document).ready(function()
{
$('#jobcontainer img').each(function() {
if($(this).height()>50) {
$(this).addClass('reduceheight')
}
})
<style>
.reduceheight { width:40%;}
</style>
<table id="jobcontainer" width="100%" border="0" cellpadding="0" cellspacing="0">
<tr class="dknytliste">
<td width="138" valign="top" class="dknytliste" style="padding-right:1em;"><p><a href="" class="dknytlink" title=""></a></p></td>
<td><a href="" class="dknytlink" title=""><img src="" /> </a></td>
</tr>
<tr> </tr>
</table>
看看這裏:http://dknyt.dk/forside/index2.php其右邊的jobcontainer。
幫助將非常apprciated。
在什麼「點擊」,它只在頁面重新加載時才加載? – adeneo
文檔就緒和窗口加載是兩種不同的東西 –
@adeneo並不意味着點擊 - 意味着:重新加載頁面 –