我有一些代碼,我試圖在我的圖像加載完成後運行。我使用以下jQuery代碼:jQuery .load()不能在我的圖像上工作
$("#myimageid").load(function() {
alert('Image Loaded');
});
但是,彈出窗口永遠不會顯示。我無法使.load()函數正常工作!任何人都有這個問題?
我有一些代碼,我試圖在我的圖像加載完成後運行。我使用以下jQuery代碼:jQuery .load()不能在我的圖像上工作
$("#myimageid").load(function() {
alert('Image Loaded');
});
但是,彈出窗口永遠不會顯示。我無法使.load()函數正常工作!任何人都有這個問題?
如果您在之後運行此圖像已經有設置源,則需要對緩存圖像(在添加事件處理程序偵聽它之前觸發該事件的人員)進行額外檢查。你可以是這樣做的:
$("#myimageid").on('load', function() {
alert('Image Loaded');
}).each(function() {
if(this.complete) $(this).load();
});
更新更高版本的查詢,使用方法:
if(this.complete) $(this).trigger('load');
使用(this).load();
會產生一個錯誤Cannot read property 'indexOf' of undefined
工作!感謝隊友 $(document).ready(function(){(「#googleimage」)。load(function(){ alert('Image Loaded'); })。each(function(){if (this.complete)$(this).load();}); }); – 2010-08-30 12:50:00
不錯,爲什麼這麼難找到! – 2012-09-18 09:56:49
當我意識到我在選擇課程時錯過了一個小點時,我只是想爲不工作的解決方案付出代價。咄!感謝和upvoted! – 2013-05-10 19:41:58
凡到底有沒有你放置的代碼? – Pointy 2010-08-27 21:04:41