Roysh
Roysh

Reputation: 1550

jQuery plugin - How to pass a parameter

I have this plugin that should receive an integer as a parameter

('foo').myplugin(3);

How do I pass the parameter to the plugin function?

I have tried something like this -

$.fn.myplugin = function(int){
alert(int);  
}   //suppose to alert "3"

yet, it doesn't seem to work

Upvotes: 0

Views: 52

Answers (1)

Curtis
Curtis

Reputation: 103348

You need $ at the start of your statement:

$('foo').myplugin(3);

http://jsfiddle.net/NxP4p/

Upvotes: 1

Related Questions