WHATWG DOM和HTML標準的JavaScript實現:jsdom
jsdom 是 WHATWG DOM 和 HTML 標準的 JavaScript 實現,主要用于 io.js 框架。
示例代碼:
// Count all of the links from the io.js build page var jsdom = require("jsdom"); jsdom.env( "https://iojs.org/dist/", ["http://code.jquery.com/jquery.js"], function (errors, window) { console.log("there have been", window.$("a").length - 4, "io.js releases!"); } );
或者:
// Run some jQuery on a html fragment var jsdom = require("jsdom"); jsdom.env( '<p><a class="the-link" , ["http://code.jquery.com/jquery.js"], function (errors, window) { console.log("contents of a.the-link:", window.$("a.the-link").text()); } );
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!