How to create a jQuery function (a new jQuery method or plugin)?

I know that in JavaScript the syntax is as follows:

function myfunction(param){
  //some code
}

Is there a way to declare a function in jQuery that can be added to an element? For example:

$('#my_div').myfunction()

14 Answers
14

Leave a Comment