Getting information from nested div and class in HTML with javascriptAsk Question


I'm trying to get to the div class="article" nested inside a div called div id="tabs=main from this a HTML-page that looks like this:


I have tried something like this but with no result:

var targetAbs = doc.querySelectorAll("article");

Anyone have any tips for me? Not even sure I'm suppose to use this queryselector. I have also tried the getElementsByClassName, but I think since it's nested I can reach it.


doc isn't a standard variable provided by the browser. You are looking for document.

Class selectors begin with a .. "article" is a type selector and will match <article> elements.


As your element has a class of article, you need to use the following code:


You need to place a . in front of the selector when it is referring to a class.

标签: html
© 2014 TuiCode, Inc.