How to get value by class name in JavaScript or jquery?

前端 未结 3 884
-上瘾入骨i
-上瘾入骨i 2020-12-16 23:23

i wan to retrive all the value of this code using class name ..is it possible in jquery . i want to retrive only the text within a div or number of div may be change the nex

3条回答
  •  失恋的感觉
    2020-12-16 23:55

    Try this:

    $(document).ready(function(){
        var yourArray = [];
        $("span.HOEnZb").find("div").each(function(){
            if(($.trim($(this).text()).length>0)){
             yourArray.push($(this).text());
            }
        });
    });
    

    DEMO

提交回复
热议问题