(function ($) {
//删除元素行内style中单个style和多个style
//示例:
//$(".b").removeCss("color");
//$(".b").removeCss(["color", "border", "width"]);
$.fn.removeCss = function (options) {
var type = typeof (options);
if (type === "string") {
this.each(function () {
var style = $(this).attr("style");
var arr = style.split(";");
style = "";
for (var i = ; i < arr.length; i++) {
if ($.trim(arr[i]) == "") {
continue;
}
var att = arr[i].split(":");
if ($.trim(att[]) == $.trim(options)) {
continue;
}
style += $.trim(arr[i]) + ";";
}
$(this).attr("style", style);
});
} else if ($.isArray(options)) {
this.each(function () {
var style = $(this).attr("style");
var arr = style.split(";");
style = "";
for (var i = ; i < arr.length; i++) {
for (var j = ; j < options.length; j++) {
if ($.trim(arr[i]) == "") {
break;
}
var att = arr[i].split(":");
if ($.trim(att[]) == $.trim(options[j])) {
arr[i] = "";
continue;
}
}
}
for (var i = ; i < arr.length; i++) {
if ($.trim(arr[i]) != "") {
style += $.trim(arr[i]) + ";";
}
}
if ($.trim(style) == "") {
$(this).removeAttr("style");
} else {
$(this).attr("style", style);
}
});
}
};
})(jQuery)