如何删除jquery添加的样式属性

2023-12-27

我正在使用具有一些自定义要求的 devExpress 表。

(更新) 休息了一天,然后回去并使用 React Styling 正确完成了它!感谢您的建议

在屏幕截图中,我禁用了某些单元格。但是,用户希望除所选行之外的所有单元格看起来均已禁用。

使用这个

   window
  .$("td")
  .not(document.getElementById(this.state.selection[0]))
  .not(document.getElementsByClassName(this.state.selection[0]))
  .not("td:first-child")
  .not(window.$("td:contains('iPlay')"))
  .not(window.$("td:contains('iLOE')"))
  .not(window.$("td:contains('iInvest')"))
  .not(window.$("td:contains('SPACER')"))
  .not(window.$("td:contains('$MM')"))
  .not(window.$("td:contains('$/BOE')"))
  .attr("style", "color:#868a8f");
window
  .$("td > div > div > div > input")
  .not(document.getElementsByClassName(this.state.selection[0]))
  .attr("style", "color:#868a8f");

I managed to achieve my desired result on page load SCREENSHOT2

我的问题是,当我选择一个新行时,我无法删除之前未选择时应用的颜色。我试图使用“has”来查找所选行并将颜色更改回继承或完全删除样式属性。

    window
  .$("td")
  .has(document.getElementById(this.state.selection[0]))
  .has(document.getElementsByClassName(this.state.selection[0]))
  .not("td:first-child")
  .not(window.$("td:contains('iPlay')"))
  .not(window.$("td:contains('iLOE')"))
  .not(window.$("td:contains('iInvest')"))
  .not(window.$("td:contains('SPACER')"))
  .not(window.$("td:contains('$MM')"))
  .not(window.$("td:contains('$/BOE')"))
  .attr("style", "color:inherit");
window
  .$("td > div > div > div > input")
  .has(document.getElementsByClassName(this.state.selection[0]))
  .attr("style", "color:inherit");

如果有帮助的话,我确实有未选择的行的 ID。 我尝试用它做点什么,但没有运气

  const otherRows = ExpensesUtils.ROW_PROPS.filter(x => x !== this.state.selection[0]);
for (let i = 0; i < otherRows.length; i += 1) {
  window
  .$("td")
  .has(document.getElementById(otherRows[i]))
  .has(document.getElementsByClassName(otherRows[i]))
  .attr("style", "color:inherit");
  window
  .$("td > div > div > div > input")
  .has(document.getElementById(otherRows[i]))
  .has(document.getElementsByClassName(otherRows[i]))
  .attr("style", "color:inherit");
}

链接到 HTML表格 HTML https://jsfiddle.net/texas697/j4anvqhw/

this.state.selection[0] 是从下面的列表中选择的 rowId

我已将 rowIds 应用于嵌套组件中的类。我想不出另一种方法来访问它们。

  const ROW_PROPS = [
  "leaseAndWellExpense",
  "leaseAndWellExpenseBoe",
  "iloeLeaseAndWellExpense",
  "iloeLeaseAndWellExpenseBoe",
  "gnaLeaseAndWell",
  "gnaLeaseAndWellBoe",
  "transportation",
  "transportationBoe",
  "divisionGnA",
  "divisionGnABoe",
  "gatheringProcessing",
  "gatheringProcessingBoe",
  "hqGnA",
  "hqGnABoe",
  "interestExpense",
  "interestExpenseBoe",
  "netProdBoe",
  "leaseImpairments",
  "leaseImpairmentsBoe",
  "ddaProducing",
  "ddaProducingBoe",
  "iInvestDdaProducing",
  "iInvestDdaProducingBoe",
  "ddaGatheringProcessing",
  "ddaGatheringProcessingBoe",
  "iInvestDdaGatheringProcessing",
  "iInvestDdaGatheringProcessingBoe",
  "marketingCosts",
  "otherIncomeExpense",
  "otherIncomeExpenseBoe",
  "otherRevenue",
  "incomeTaxProvision",
  "incomeTaxProvisionBoe",
  "severanceTaxes",
  "severanceTaxesPercent",
  "currentTaxes",
  "currentTaxesRate",
  "netWellHeadRevenue",
];

最简单的方法是创建 CSS 规则的样式表。

在该样式表中,您应该定义2 节课.

假设 1 代表您想要的 CSS 规则,另一个代表默认/无规则。

我只是向您展示做这件事的最简单版本,但还有另一个方面。

$('#b1').on('click', function() {
  $('.c1').removeClass('c1');
  $(this).addClass('c2');
});
.c1 {
  color: red;
}

.c2 {
  color: green;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<button id="b1">Change</button>
<p class="c1">This is a Test Line.</p>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何删除jquery添加的样式属性 的相关文章

随机推荐

  • 发挥框架2.0的演变并创建触发器

    我一直在尝试使用 Play 2 0 3 创建此触发器 如果我手动运行它 它在 MySQL 中运行得很好 但当尝试从 Play 运行它时 它会失败 delimiter create trigger company updated before
  • Java 反射和重构中的痛苦

    Java Reflection 提供了一种在运行时自省对象的机制 毫不犹豫 这是一个很棒的功能 但它打破了所有重构约定 没有简单的方法 除了File Search 甚至在现代 IDE 中也能知道引用了哪个属性以及在哪里引用 这使得重构变得更
  • apache,允许文件名带有“?”

    我想制作网站的静态副本 保留现有的 URL 问题是 URL 看起来像 http mysite index php id XXX http mysite index php id XXX Apache 不想找到文件 index php id
  • 如何知道Android是否连接到WiFi或以太网? [关闭]

    Closed 这个问题需要多问focused help closed questions 目前不接受答案 How to know whether I m connected to WiFi or ethernet in Android In
  • 使用一种编译器创建的静态 C 库是否与另一种编译器兼容?

    就我而言 我有一个使用代码源 gcc 构建的库 目标是arm cortex m4 然后我尝试将该库链接到使用 IAR 编译器编译的项目中 是否可以做到这一点 或者是否必须使用新工具重建库 哪些因素影响这个 静态库是几个目标文件的捆绑 这些目
  • Seaborn 散点图将气泡大小缩放为更大的点

    我正在关注这个example https seaborn pydata org generated seaborn scatterplot html我想创建更大的气泡 但无论我将尺寸列乘以多大 它们仍然很小 是否需要调整某种比例因子 我在文
  • 为什么这个 IFrame 没有占据完整的页面高度? [复制]

    这个问题在这里已经有答案了 我正在使用 Iframe 来显示 google com 或说任何网站 我使用了 height 100 但即便如此 我的 Iframe 大小也只是页面的一半 请让我知道为什么会发生这种情况 链接在这里 http j
  • Spark:测试 RDD 是否为空的有效方法

    没有一个isEmptyRDD 上的方法 那么测试 RDD 是否为空的最有效方法是什么 RDD isEmpty https issues apache org jira browse SPARK 5270将成为 Spark 1 3 0 的一部
  • 与PHP在同一页面显示结果

    我基本上是从 PHP 开始学习的 我想做的事情很简单 我想在同一页面显示计算结果 这是项目的结构 https i stack imgur com XGPVr png Code 索引 php header php
  • WAMP、Laravel 5:路由不起作用 - NotFoundHttpException

    我在本地计算机上使用 Laravel 5 和 WAMP 没有虚拟化 使用 Composer 创建一个名为 LaravelProject 的新项目后 我似乎根本无法让我的路线正常工作 我已经做了什么 Edited httpd conf to
  • 查找:显示模板速度

    我在新的 MVC4 站点上安装了 Mini Profiler 并注意到某些功能的等待时间很长Find DisplayTemplates包括字符串和日期时间 下面是一个例子 在另一个问题中 Sam Saffron 谈到了查找步骤 在随后的运行
  • 理解c++20中的convertible_to概念

    我对 C 20 概念仍然很陌生 我想知道为什么这不起作用 我想创建一个将数字连接为字符串的函数模板 所以我想尝试一些概念 我用了std convertible to检查输入的数据类型 即int在这种情况下 可以转换为std string 但
  • UICollectionView 标题宽度

    在我的 UICollectionViewFlowLayout 子类中 我有这个 self headerReferenceSize CGSizeMake 280 44 但是 标题的显示宽度为 320 这是集合视图的宽度 根据文档 这是正确的
  • 处理 Express 表单中的输入数组?

    假设我必须在同一页面上编辑一批相同类型的对象 jade form action method POST for each message id in messages ids input type text name message id
  • 如何删除Android searchview左侧的空间(不属于actionbar的一部分)?

    我在 android 应用程序中使用 searchview searchview 不是操作栏的一部分 我想删除搜索图标 搜索视图左侧的空格 我搜索了很多并收到了适用于作为操作栏一部分的搜索视图的答案 我尝试使用机器人 布局重力 机器人 重力
  • 为什么 const char* const & = "hello" 可以编译?

    我正在阅读一本书中的代码片段并发现 const char const a hello can compile const char a hello cannot 我所知道的是 在初始化引用时 数组到指针的转换不会发生 const char
  • graphstudio 中可用的引脚在代码中不存在

    我正在使用网络摄像头的源过滤器 当我在 graphstudio 中使用过滤器时 它有两个输出引脚 然而 在代码中 对 IEnumPins gt next 的调用始终返回 S FALSE 我还寻找了另一个可以创建引脚的接口 但没有找到这样的东
  • PHP S3上传进度

    这种情况已经发生过很多次了 但我仍然有点困惑 很多答案只关注谈论上传进度条 而不是从 S3 上传获取实际的上传进度 我已经阅读了很多问题并找到了很多软件 但我仍然没有更深入地理解 S3 上传的基本问题 有没有一种方法可以上传到 S3 同时了
  • “TypeError:item.getAttachmentsAsync 不是函数”Outlook 加载项 office-js 与 Vue

    我一直在关注此链接中的教程 https learn microsoft com en us javascript api outlook office messageread view outlook js preview getAttac
  • 如何删除jquery添加的样式属性

    我正在使用具有一些自定义要求的 devExpress 表 更新 休息了一天 然后回去并使用 React Styling 正确完成了它 感谢您的建议 在屏幕截图中 我禁用了某些单元格 但是 用户希望除所选行之外的所有单元格看起来均已禁用 使用