Is there a way to have javascript make an array of all the internal href=#’s on a page?
The idea is to have a drop down menu that would contain links to all anchors on a page.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Depending on the browser support you need, you can do this:
You can gain support for older browsers using the shims provided by MDN.
map()[docs]filter()[docs]indexOf()[docs]In your comment, you noted that you want the
nameinstead of thehref.You can do this, and it brings greater browser support automatically, though you’ll still want to get support for
indexOf().