17-10.js

来自「js 全的样例代码,比较适合大家学习和交流」· JavaScript 代码 · 共 18 行

JS
18
字号
// Define a NodeFilter function to accept only <img> elementsfunction imgfilter(n) {   if (n.tagName == 'IMG') return NodeFilter.FILTER_ACCEPT;   else return NodeFilter.FILTER_SKIP;}// Create a NodeIterator to find <img> tagsvar images = document.createNodeIterator(document, // traverse entire document	/* only look at Element nodes */ NodeFilter.SHOW_ELEMENT,	  /* filter out all but <img> */ imgfilter,	  /* unused in HTML documents */ false);// Use the iterator to loop through all images and do something with themvar image;while((image = images.nextNode()) != null) {    image.style.visibility = "hidden";  // Process the image here}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?