/**
* Created by RATDATA on 2016/8/30.
*/
(function ($) {
$.fn.extend({
"ButtonOFF": function (key) {
///<summary>
/// 按鈕不可用
///</summary>
if (key==undefined)
{
key='數據加載中...';
}
this.val(key) //設置按鈕顯示文字
this.css({ background: "#A1A1A1" });
this.attr('disabled',"true");
},
"ButtonON": function (key) {
///<summary>
/// 按鈕可用
///</summary>
if (key!=undefined)
{
this.val(key)
//設置按鈕顯示文字//沒有就不改變文字
} this.css({ background: "#21c284" });
this.removeAttr("disabled"); },
});
})(jQuery);
調用方法
$(this).ButtonOFF('發送中...');
this.ButtonOFF('發送中...');
因爲在經常處理ajax的時候要鎖定按鈕以及變換按鈕顏色,所以寫個jquery插件方便點
</pre><pre>