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
}
}
精彩评论