1
我目前正在学习如何创建jQuery插件,并且已经创建了下面的代码。我添加了自己的功能,并在为我的插件添加默认设置后扩展了选项,但没有任何事情发生。我甚至添加了一个警报 - 但它也没有显示。我的jQuery插件的语法有什么问题?
这里是我到目前为止的代码:
(function($){
// Extend the Jquery Object with the Myedit Function
jQuery.fn.Myedit = function(options) {
// Default options
var defaults = {
width: 250,
height: 20,
url: "",
data: {},
buttons: false
};
// Extend the options with the onse the user provided
var options = $.extend(defaults, options);
return this.each(function() {
var object = $(this);
$(object).live('click', function() {
var input = $('<input />', {'type': 'text', 'name': $(this).attr('name'), 'value': $(this).html()});
$(this).parent().append(input);
$(this).remove();
input.focus();
});
$(object).live('blur', function() {
$(this).parent().append($('<span />').html($(this).val()));
$(this).remove();
});
$(this).hide();
});
};
//return alert(object);
})(jQuery);
我在做什么错?
谢谢你的好信息:D – test 2013-05-03 22:39:43
没问题..很高兴它给了你一些提示或信息.. :) – PSL 2013-05-03 22:40:12