当前位置:网站首页>JQ remove an element style
JQ remove an element style
2022-07-24 13:38:00 【Amitabha @ Moda】
perform
// Example :
//$(".select").removeCss("color");
//$(".select").removeCss(["color", "border", "width"]);
(function ($) {
$.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 = 0; i < arr.length; i++) {
if ($.trim(arr[i]) == "") {
continue;
}
var att = arr[i].split(":");
if ($.trim(att[0]) == $.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 = 0; i < arr.length; i++) {
for (var j = 0; j < options.length; j++) {
if ($.trim(arr[i]) == "") {
break;
}
var att = arr[i].split(":");
if ($.trim(att[0]) == $.trim(options[j])) {
arr[i] = "";
continue;
}
}
}
for (var i = 0; i < arr.length; i++) {
if ($.trim(arr[i]) != "") {
style += $.trim(arr[i]) + ";";
}
}
if ($.trim(style) == "") {
$(this).removeAttr("style");
} else {
$(this).attr("style", style);
}
});
}
};
})(jQuery)
边栏推荐
猜你喜欢

Go deadlock problem

LeadTools 22 kit LeadTools super set

Implementation of dynamic columns in EAS BOS doc list

【论文阅读】Mean teachers are better role models

Simulate the implementation of the library function memcpy-- copy memory blocks. Understand memory overlap and accurate replication in detail

Paper notes: swing UNET: UNET like pure transformer for medicalimage segmentation

Unity UGUI中scroll bar在游戏中启动界面时没有从最上面显示

Network security - file upload penetration test

Modern data architecture selection: Data fabric, data mesh

From cloud native to intelligent, in-depth interpretation of the industry's first "best practice map of live video technology"
随机推荐
Search engine based on boost library
C code specification
网络安全——过滤绕过注入
Browser type judgment
Mongodb uses mongotemplate operations to add, delete, modify, query, page, sort, aggregate (including embedded data), file upload and download
基于典型相关分析的多视图学习方法综述
Swarm intelligence collaborative obstacle avoidance method inspired by brain attention mechanism
Basic operation of file
支持鹏程系列开源大模型应用生态演化的可持续学习能力探索
Research and progress of traffic situation awareness based on social media data enhancement
Embedded cognitive network card PHY self negotiation
网络安全——报错注入
Aggregation measurement of robot swarm intelligence based on group entropy
Kunyu(坤舆) 安装 详解
Can communication protocol (I)
Knowledge sharing | sharing some methods to improve the level of enterprise document management
The use of two-dimensional array (including the definition of two-dimensional array, the declaration and initialization of two-dimensional array (dynamic initialization, static initialization), common
Thread multithreading
How can the easycvr platform access special devices without authentication?
游戏思考04总结:针对帧、状态、物理同步的总结(之前写的太长,现在简略下)