【发布时间】:2015-07-09 03:35:12
【问题描述】:
我有一个按钮:
<button id="btn:1:uniquenamehere">btn</button>
中间的数字有时会因其他框架的内部运作而发生变化。无论中间的数字是多少,我都需要能够找到这个按钮。所以我需要通过只有中间数字会改变的模式来找到它。所以我需要这样的东西:
document.getElementById("btn:*:uniquenamehere")
我看到了使用 jquery 的方法,但我不能使用 3rd 方库。如何使用纯 javascript 做到这一点?
【问题讨论】:
-
你能不能只为这些按钮添加一个类,然后通过它们的类名查找它们?
标签: javascript pattern-matching