(function($){
$.fn.btn = function(){
var btn = this.data("_self");;
if(btn){
return btn;
};
this.init = function(){
var obj = $(this);
var id=$(this).attr('id')||"gen"+Math.random();
var icon = $(this).attr('icon')||'icon-btncom';
var bntStr=[
'<table id="',id,'" class="z-btn" cellSpacing=0 cellPadding=0 border=0><tbody><tr>',
'<TD class=z-btn-left><i>&nbsp;</i></TD>',
'<TD class=z-btn-center><EM unselectable="on">',
'<BUTTON class="z-btn-text ',icon,'" >',$(this).attr('value'),'</BUTTON>',
'</EM></TD>',
'<TD class=z-btn-right><i>&nbsp;</i></TD>',
'</tr></tbody></table>'
];
var bnt = $(bntStr.join('')).btn();
bnt._click = eval(obj.attr("onclick")); bnt.disable();
if(obj.attr("disabled"))
bnt.disable();
else bnt.enable();
$(this).replaceWith(bnt);
bnt.data("_self", bnt);  
return bnt;
};
this.enable = function(){
this.removeClass("z-btn-dsb");
this.click(this._click);
this.hover(
  function () {
    $(this).addClass("z-btn-over");
  },
  function () {
    $(this).removeClass("z-btn-over");
  }
)
};
this.disable = function(){
 this.addClass("z-btn-dsb");
 this.unbind("hover");
 this.unbind("click");
};  
return this;
};

$(function(){
$("input[type='button']").each(function(){
$(this).btn().init();
});
$("input[type='reset']").each(function(){
$(this).btn().init().click(function(){
var form = $(this).parents("form")[0];
if(form)
form.reset();
});
});
$("input[type='submit']").each(function(){
$(this).btn().init().click(function(){
var form = $(this).parents("form")[0];
if(form)
form.submit();
});
});
})
})(jQuery);
求大侠帮我看下...为什么
<input icon='icon-delete' type='button' value='删除' onclick="alert('OK')"/>页面一刷新就直接执行alert了,用jquery1.3正常1.8就直接执行了
是不是这句有问题啊
bnt._click = eval(obj.attr("onclick"));
是不是应该用bind绑定啊...
具体怎么弄不会啊,新手麻烦给修改下啊...