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