I have the following simplified function. Real usage removed. So, onfocus I expect the value of the textbox to be alerted.
I would like to keep the function definition separate from the usage.
new function ($)
{
$.fn.setFocus = function ()
{
alert($(this).val());
}
} (jQuery);
My current attempt is not working:
$('input[type=text]').focus(setFocus);
How can I get this to work? thanks.
setFocusis probably not defined. You should refer to the function itself, in this case$.fn.setFocus.