我在网格视图中有一个带有动态生成的超链接的网页。每个超链接都应该是一个相应的按钮,除了调用链接之外什么都不做。如何从我的 clientclick 按钮事件中引用 href 属性并调用它?
问问题
44 次
1 回答
0
根据您检索超链接的方式,您可以执行以下操作:
html:
<a id="dyn_link_00" href="https://duckduckgo.com/" target="_blank">Duck, duck, GO!!!!</a>
Javascript:
// we assume that the current index is 00 and link is defined in scope.
link = document.getElementById('dyn_link_' + currentIndex);
console.log(link.href.toString()); // yields https://duckduckgo.com/
// (toString() might not be necessary)
于 2013-11-05T22:58:04.917 回答