Home  >  Article  >  Web Front-end  >  How to install jquery on mac (steps)

How to install jquery on mac (steps)

PHPz
PHPzOriginal
2023-04-07 09:02:541211browse

Installing jQuery on your Mac computer is very simple, just follow these steps:

Step 1: Download jQuery

First, you need to visit the jQuery official website (https:// jquery.com/) and click the Download button. You should see two download options: a compressed version and an uncompressed version. During this process, we will download the compressed version, which is a file called "jquery-x.x.x.min.js", where x.x.x represents the current version number.

Step 2: Open the text editor

Now, you need to open the text editor. The text editor that comes with Mac is TextEdit. You can find it in the Applications folder. If you want to use another text editor like Sublime Text or Atom, that's also possible.

Step 3: Create a new file

In the text editor that opens, click the "File" menu and select the "New File" option. Alternatively, you can use the shortcut "Command N" to create a new file.

Step Four: Add jQuery Code

Now, you need to paste the downloaded jQuery file contents into the file you just created. Make sure to paste the content into a plain text editor to avoid any formatting issues.

The content of the jQuery file looks like this:

/*! jQuery v3.5.1 | (c) JS Foundation and other contributors | jquery.org/license */
!function(e,t){ "use strict"; "object"==typeof module&&"object"==typeof module.exports? module.exports=e.document?t(e,!0):function(e){ if(!e.document) throw new Error("jQuery requires a window with a document"); return t(e) }:t(e)}("undefined"!=typeof window?window:this,function(e,t){ "use strict"; var n=[],r=e.document,i=Object.getPrototypeOf,o=n.slice,a=n.concat,s=n.push,u=n.indexOf,l={},c=l.toString,f=l.hasOwnProperty,p=f.toString,d=p.call(Object),h={},g=function(e){ return"function"==typeof e&&"number"!=typeof e.nodeType},
.
.
.(此处省略...)

Step Five: Save the File

Now, you need to save the file to your Mac computer. Click the File menu and select the Save option. Just name the file "jquery.js" and save it wherever you want.

Step 6: Link the jQuery file to your HTML file

The last step is to link the jQuery file to your HTML file. To achieve this step, you need to add a