I have the following code:
(function(jQuery){
jQuery.fn.timepicker = function(){
return this.each(function(){
jQuery(this).val("14:00");
});
};
})(jQuery);
Currently I invoke thi开发者_运维技巧s function by the following code: $("#event_start_time").timepicker();
Where #event_start_time
is the ID of an <input>
field.
I do not want to invoke the plugin by using something like this:
$('#event_start_time"').click(function() {
this.timepicker();
});
How can I invoke this code only when I click inside the text box?
Hmm... this place isn't as quick as it used to be :(
I found the answer. Here's the code:
(function(jQuery){
jQuery.fn.timepicker = function(){
return this.each(function(){
obj = $(this);
obj.click(function () {
alert('test');
});
});
};
})(jQuery);
精彩评论