首页 > 解决方案 > 如何排除具有特定 ID 的表?

问题描述

我需要 jQuery 的帮助。
我需要在我的if声明中添加表格不能id“pippo”的条件。

我的if声明如下:

if (
  HtmlPath.indexOf('ZOSHTML/DTREND') > -1 || 
  HtlPath.indexOf('LNXHTML/DTREND/LDRSYS.') > -1 || 
  HtmlPath.indexOf('LNXHTML/DTREND/LDMAIN.') > -1 &&
  // put here the condition that the table must not contain the ID pippo
) {
  $("table.NAVREP").epvMinMax();
}

标签: jquery

解决方案


您可以使用 jQueryattr函数来检查该id属性是否不是“pippo”:

if (
  HtmlPath.indexOf('ZOSHTML/DTREND') > -1 ||
  HtmlPath.indexOf('LNXHTML/DTREND/LDRSYS.') > -1 ||
  HtmlPath.indexOf('LNXHTML/DTREND/LDMAIN.') > -1 &&
  $('table').attr('id') != 'pippo'
) {
  $('table.NAVREP').epvMinMax();
}

推荐阅读