代码如下:
jquery-highlight.js
复制代码 代码如下:
(function($) {
$.fn.highlight = function(options) {
var defaultOpt = {
lightColor: 'yellow',
lightTime: 1000,
isFocus: true
};
options = $.extend(defaultOpt, options);
return this.each(function() {
var sender = $(this);
if (sender.attr('light') == undefined) {
var _bgColor = sender.css('background-color');
sender.css({ 'background-color': options.lightColor });
if (options.isFocus) {
sender.focus();
}
sender.attr('light', true);
window.setTimeout(function() {
sender.removeAttr('light');
sender.css({ 'background-color': _bgColor });
}, options.lightTime);
}
});
}
})(jQuery);
Html代码:
复制代码 代码如下:
调用方法:
复制代码 代码如下:
效果如下:



