【问题标题】:How to get the table name that contains a certain ID? [duplicate]如何获取包含某个ID的表名? [复制]
【发布时间】:2019-05-28 14:52:38
【问题描述】:

我有几个表,其中包含带有单词“MRCPUBSY”的 ID (例如:TABLE ID="_MIPS-MRCPUBSY")。

如果我只知道 ID NAME 的一部分,如何获得这张表?

我想使用类似的东西: var MyTable = document.getElementById('MRCPUBSY'.value) 但这不行,因为 ID 的名称是 _MIPS-MRCPUBSY 而不仅仅是 MRCPUBSY。

【问题讨论】:

  • 能否添加相关代码?

标签: javascript


【解决方案1】:

您可以使用attribute contains selector[id*=MRCPUBSY]

例如,获取第一个这样的表:

var myTable = document.querySelector("[id*=MRCPUBSY]");

【讨论】:

    【解决方案2】:

    使用attribute contains selector

    document.querySelector("[id*='MRCPUBSY']").value;
    

    【讨论】:

    • 感谢您的回答
    猜你喜欢
    • 2012-03-14
    • 2017-06-08
    • 1970-01-01
    • 2021-12-29
    • 2016-08-07
    • 2011-03-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多