开发者

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

开发者 https://www.devze.com 2023-01-19 02:25 出处:网络
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...

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

精彩评论

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