In JavaScript, suppose I have a DOM element in a variable like this:
var first_part = document.querySelectorAll('.sizes.row > .selectric-wrapper > .selectric-items > .selectric-scroll > ul > li')
This returns an array with several list items.
Now I'd like to query somewhat deeper, but in my code, it depends which 'route' to take.
In some cases (name it 'scenario 1') I need this path:
document.querySelectorAll('.sizes.row > .selectric-wrapper > .selectric-items > .selectric-scroll > ul > li')[0].className
In other cases (name it 'scenario 2') I need this path:
document.querySelectorAll('.sizes.row > .selectric-wrapper > .selectric-items > .selectric-scroll > ul > li')[0].children[0].title
So what I tried was:
var second_part = ['[0].className','[0].children[0].title']
And then refer to for example scenario 1 like this:
var scenario_1 = first_part + second_part[0]
The result is this
"[object NodeList][0].className"
This is not what is required; I'd like to get the value of the className.
Does anyone know how to solve this?