【问题标题】:C# Get Value from ID when ID changes Slightly当 ID 发生轻微变化时 C# 从 ID 中获取值
【发布时间】:2015-05-29 18:14:29
【问题描述】:

我正在尝试从每次都略有变化的 ID 中获取价值。

例如我有这个:

<img id="economy_item_#######_item_icon" alt="Dual Berettas | Colony">

我正在尝试检索“Dual Berettas | Colony”,但我放置 # 的位置是一个每次都会更改的数字。我怎样才能做到这一点?

感谢任何和所有的帮助。

谢谢

【问题讨论】:

  • 尝试使用模式 [0-9]* 的正则表达式

标签: c# automation webbrowser-control steam


【解决方案1】:

您可以使用 jQuery 属性包含功能。 https://api.jquery.com/attribute-contains-selector/

像这样:

var txt = $("img[id*='economy_item_']").attr('alt');

【讨论】:

    猜你喜欢
    • 2021-07-09
    • 1970-01-01
    • 2018-11-23
    • 1970-01-01
    • 2022-01-19
    • 2012-07-05
    • 2016-06-24
    • 2011-10-20
    • 2023-01-31
    相关资源
    最近更新 更多