Front/JS & jQuery

[jQuery] trigger() parameter 사용하기

오선지♬ 2023. 8. 4. 15:45
728x90
반응형

https://api.jquery.com/trigger/

 

.trigger() | jQuery API Documentation

Description: Execute all handlers and behaviors attached to the matched elements for the given event type. Any event handlers attached with .on() or one of its shortcut methods are triggered when the corresponding event occurs. They can be fired manually,

api.jquery.com

 

$( "#foo" ).on( "custom", function( event, param1, param2 ) {
  alert( param1 + "\n" + param2 );
});
$( "#foo").trigger( "custom", [ "Custom", "Event" ] );

trigger 를 발생시키고 parameter 를 보내면

function( event, param1, param2 •••) 이렇게 받아서 쓸수 있다.

728x90
반응형