开发者

how do i select all a tags with href="#xyz"

using pure javascrip开发者_JAVA百科t can i select all a tags with href="#xyz". And also i would like to trigger some event while clicking on that element too...

how can i do that?

PS: pure javascript means without using jquery or other frameworks


for (i=0;i<=document.links.length;i++) {
  if (document.links[i].href == '#xyz') {
    // here you will have "selected only the ones with #xyz
    // Just be careful with the test, it will require a http://..../ I believe
  }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜