このコード スニペットが IE8 以前で機能しない理由を教えてください。エラーはスローされませんが、実行されていないようです。
$('<img/>')
.attr('src', $('.my_div img:first').attr('src'))
.load(function(){
console.log('hello');
alert('hello');
});
ありがとう。
このコード スニペットが IE8 以前で機能しない理由を教えてください。エラーはスローされませんが、実行されていないようです。
$('<img/>')
.attr('src', $('.my_div img:first').attr('src'))
.load(function(){
console.log('hello');
alert('hello');
});
ありがとう。
IE8では、イベントハンドラーを設定する前にロードイベントが発生します。ソース属性を設定する前に、ロードイベントを設定します。
$('<img/>').load(function(){
console.log('hello');
}).attr('src', $('.my_div img:first').attr('src'));
デモ: http: //jsfiddle.net/Guffa/GRKJE/