Can I use jQuery with Node.js?

前端 未结 20 1633
清歌不尽
清歌不尽 2020-11-22 05:42

Is it possible to use jQuery selectors/DOM manipulation on the server-side using Node.js?

20条回答
  •  长发绾君心
    2020-11-22 06:17

    First of all install it

    npm install jquery -S
    

    After installing it, you can use it as below

    import $ from 'jquery';
    window.jQuery = window.$ = $;
    $(selector).hide();
    

    You can check out a full tutorial that I wrote here: https://medium.com/fbdevclagos/how-to-use-jquery-on-node-df731bd6abc7

提交回复
热议问题