| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2508 人关注过本帖
标题:JS脚本,运行环境chrome油猴,打印变量明明HTMLCollection里有元素,却获取 ...
只看楼主 加入收藏
legendary_br
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2018-8-28
收藏
 问题点数:0 回复次数:0 
JS脚本,运行环境chrome油猴,打印变量明明HTMLCollection里有元素,却获取不到?
// ==UserScript==
// @name         微博搜索页净化
// @namespace    http://
// @version      0.1
// @description  净化微博搜索页面,去除热门和推广。
// @author       chuan
// @match        http://s.*
// @grant        none
// ==/UserScript==

(function() {
   var rightEle = document.getElementById("pl_weibo_directright");
    rightEle.style.display = "none";
    var hotband = document.getElementById("pl_weibo_hotband");
    hotband.style.display = "none";
    var nodes = document.getElementById("pl_weibo_direct").children;
     console.log(nodes);
    console.log(nodes==null);
    console.log(nodes.length);
    console.log(nodes[0]);
  var elements = document.getElementById("pl_weibo_direct").firstElementChild.children;

    console.log(elements);
    console.log(elements.length);
    for(var i = elements.length - 4 ; i > -1 ; i--){
        elements[i].style.display = "none";
    }
})();
[local]1[/local]
[local]2[/local]

搜索更多相关主题的帖子: var document getElementById console elements 
2018-08-28 14:33
快速回复:JS脚本,运行环境chrome油猴,打印变量明明HTMLCollection里有元素,却 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.022979 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved