[英]how do i select all a tags with href=“#xyz”
using pure javascript can i select all a tags with href="#xyz". 我可以使用纯JavaScript来选择所有带有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 PS:纯JavaScript意味着无需使用jquery或其他框架
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
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.