how i can select element with double class with querySelector()

笑着哭i 提交于 2021-02-16 22:55:28

问题


i'm having problem when i want to select element using querySelector

<ul class="xoxo blogroll">
    </ul>

how i can select that ul element, in my code i'm use like this

var list = document.body.querySelector('ul[class="oxo blogroll"]');
    alert(list.innerHTML);

but the return is null,i'm sure element ul with class xoxo blogroll is defined... thanks for your answer..


回答1:


document.body.querySelector("ul.xoxo.blogroll")

And that is it...




回答2:


Try this:

document.body.querySelector('ul.xoxo.blogroll')


来源:https://stackoverflow.com/questions/8847247/how-i-can-select-element-with-double-class-with-queryselector

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!