Lucy Posted May 13, 2015 Share Posted May 13, 2015 I'm trying to pick out links with the parent '<p>' - my code isn't picking them up. Here's what I have: if (document.body.getElementsByTagName("a")[ook].parentNode === "p") I've also tried if (document.body.getElementsByTagName("a")[ook].parentNode === "<p>") Does anyone know how you're supposed to do this? Link to comment Share on other sites More sharing options...
Ingolme Posted May 13, 2015 Share Posted May 13, 2015 parentNode returns an object of type HTMLElement. If you want to know the tag name, you can use the nodeName property. The nodeName might be in uppercase, so we need to change it to lower case before testing its value. if (document.body.getElementsByTagName("a")[ook].parentNode.nodeName.toLowerCase() == "p") { Link to comment Share on other sites More sharing options...
Lucy Posted May 13, 2015 Author Share Posted May 13, 2015 Ahh... thanks very much Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now