0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

baserJSAdvent Calendar 2014

Day 14

baserJSで要素内の画像の読み込みを待つ

Posted at

コーポレートサイトにちょうどいいJavaScriptライブラリ baserJS の解説記事です。

Webサイトと詳しいAPIリファレンスはこちら baserJS Webサイト

window.onload でなく、一部の要素内の読み込みを待機

要素内に限定した画像の読み込みが完了してから発火するコールバックを登録できます。

HTML

<div class="image-container">
	<img src="a.png">
	<img src="b.png">
	<img src="c.png">
</div>

<img src="d.png">
<img src="e.png">
<img src="f.png">

JavaScript

$('.image-container').bcImageLoaded(function () {
	
	// a.png, b.png, c.png の読み込みが完了してから実行されます
	// d.png, e.png, f.png はなにも干渉しません
	
	this; // => .image-container の HTMLオブジェクト
		
});
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?