javascript – jQuery中是否有淡入淡出禁用插件?
作者:互联网
因此,我们经常遇到无法在Internet上使用的褪色对象,例如具有灰色/褪色外观的文本框,无法单击并键入.
我想对一个CSS对象做同样的事情,后来这个CSS对象不会褪色并且可以使用.
任何帮助,将不胜感激.
谢谢!
解决方法:
Is there a fade + disable plugin in jQuery?
jQuery插件
(function($) {
$.fn.fadeAndDisable = function(delay) {
delay = delay || 500;
return this.each(function() {
$(this).fadeTo(0.5, delay, function() {
$(this).attr('disabled', 'disabled');
})
});
}
$.fn.fadeAndEnable = function(delay) {
delay = delay || 500;
return this.each(function() {
$(this).fadeTo(1, delay, function() {
$(this).removeAttr('disabled');
})
});
}
})(jQuery);
用法
$('input').fadeAndDisable(1000);
$('input').fadeAndEnable(1000);
您可能希望扩展它以允许回调,这是很容易添加的.
标签:javascript,jquery,jquery-animate 来源: https://codeday.me/bug/20190726/1543621.html