简体   繁体   中英

Node.js dom apis - jsdom, cheerio - can I use JS commands or do I need to use jQuery?

Is there any dom api for node.js in which I can use simply JS commands? I would like to avoid using jQuery cause I already get code in JS.

If I remember correctly you can use JS code with jsdom module. By default it code example has:

var $ = window.$;

(to use jQuery) just change it to:

var document = window.document;

and you can use some JavaScript code like:

document.getElementById('yourid');

There is no jQuery to JavaScript converter cause jQuery is JavaScript. Everything you write in jQuery you can write in JavaScript - of course some of the code will be more complicated/bigger - thats why jQuery was invented (simpler code with good browser support).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM