Home >Web Front-end >JS Tutorial >jquery button status effect normal, move up, press_jquery

jquery button status effect normal, move up, press_jquery

WBOY
WBOYOriginal
2016-05-16 17:26:061105browse

In the process of web design, we often encounter the various status effects of buttons. Wrote a jquery extension to make this process more convenient!
Be sure to quote Jquery before use;
JqueryExtend.js:

Copy the code The code is as follows:

(function ($) {
//Three styles of Button button replacement, if the isState parameter is True, the pressed state is recorded
$.fn.btnEffect = function (normal, mouseover, mousedown, isState) {
var lastButton;
this.each(function () {
$(this).bind({
mouseover: function () {
if (this != lastButton | | !isState) {
$(this).removeClass().addClass(mouseover)
}
},
mouseout: function () {
if (this != lastButton || !isState) {
$(this).removeClass().addClass(normal)
}
},
mousedown: function () {
if (this != lastButton || ! isState) {
if (lastButton != null) {
$(lastButton).removeClass().addClass(normal);
}

$(this).removeClass(). addClass(mousedown);
lastButton = this;
}
}
});
});
}
})(jQuery);

Sample page Default.aspx:
Copy code The code is as follows:

< %@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="JqueryExtend_Default" %>




















Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn