test

        function test() {
            //输出html
            function out_innerHTML(objs) {
                for (var i = 0; i < objs.length; i++) {
                    //console.log(t[i]);
                    //console.log(t[i].getElementsByClassName("icon").length);
                    //console.log(t[i].innerHTML.indexOf("天猫"));

                    //console.log(t[i].innerHTML);

                    return objs[i].innerHTML.indexOf("天猫");
                }
            }
            var t = document.getElementById("mainsrp-itemlist").getElementsByClassName("item");
            //console.log(t);

            for (var i = 0; i < t.length; i++) {
                var icons_list = t[i].getElementsByClassName("icons");  //获得icon元素的集合

                if (out_innerHTML(icons_list) > 0) {

                    t[i].style.backgroundColor = "#000"; // 驼峰命名法
                    t[i].style.opacity = 1 / 100;
                    //t[i].style.color ="#000";
                } else {
                    t[i].style.backgroundColor = "aqua"; // 驼峰命名法
                }

                //console.log(t1);
            }
        }
        var i = 0;
        var int = self.setInterval(function () {
            test();
            console.log(1);
        }, 3000);

 

posted @ 2020-03-04 21:48  enych  阅读(165)  评论(0编辑  收藏  举报