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 1 year has passed since last update.

$(function(){});の意味

Last updated at Posted at 2022-10-25

はじめに

$(function(){});という書き出しで始まるこちらのコード。
特に説明をされることが無いためメモとして残しておきます。

$(function(){});について

実はこのコード、省略形になっています。
省略せずに書くと$(document).ready(function(){});となります。

つまりHTML(document)の読み込み(ready)が完了してから処理を開始するということになり、基本は省略形を使う。

サンプルコード

省略形
$(function(){

    //ここにjQueryコード

});
   
省略なし
$(document).ready(function(){

    //ここにjQueryコード

});
   
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?