Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
ウィンドウの準備ができているときにイベントをディスパッチするにはどうすればよいですか? たとえば、私のコードでは次のようになっています。
$("#info").click(function(){ // do stuff });
#info をクリックせずに、最初にこの関数を呼び出す必要があります。
.trigger()次の方法を使用できます。
.trigger()
$('#info').trigger('click');
または単に:
$('#info').click();
これは同じです。
より良い方法は、必要なことを行う関数を作成してから、$(document).ready(myFunc);andを実行すること$("#info").click(myFunc);です。
$(document).ready(myFunc);
$("#info").click(myFunc);