[jQuery] Simple Plugin for jQuery
I am trying to get a handle on creating a jQuery plugin. I have a
function that I wrote a couple of years ago that returns a formatted
email address. I want to turn that function into a jQuery plugin.
Here is my function:
[code]
function makemailto(email,subject,text)
{
// Makes a nice mailto link
var returnval;
returnval = '<a href="mailto:' + email +
'?">' + email + '</a>';
if (subject && text)
{
returnval = '<a href="mailto:' + email +
'?subject=' + subject +
'&">' + text + '</a>';
}
else if (subject)
{
returnval = '<a href="mailto:' + email +
'?subject=' + subject +
'&">' + email + '</a>';
}
else if (text)
{
returnval = '<a href="mailto:' + email +
'?">' + text + '</a>';
}
return(returnval);
}
[/code]
I cannot seem to figure out how to create a simple plugin that I can
call like this:
$.makemailto('someone@somewhere.com','Subject Here');
Any advice?
Thanks,
LJ Wilson