javascript - How to access li elements within ul tag -
i want know how access each li within ul? not sure name of ul is.
here code:
<ul class= "selectbox-options exp-pdp-size-dropdown exp-pdp-dropdown" style> <li class = " omitted"> more li here omitted </ul>
my main goal have user click size in dropdown lets size 8 , automatically detect specific li(8) inside ul
you use queryselectorall
:
var array_of_li = document.queryselectorall("ul.selectbox-options li");
if you're not sure ul
have selectbox-options
class, delete .selectbox-options
part - remember every li
on page then.
if you're using jquery, bit more compatible, , same thing:
var li = $("ul.selectbox-options li");
Comments
Post a Comment