6

This may sound stupid.

But how do you add Jquery to sublime text 2?

Can't seem to get it working.

I've added this github.

Then created a Jquery folder in my packages.

Finally I added this into my head tags.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

But still no luck.

3
  • jQuery bundle for sublime editor? Interesting. There is an instruction for adding the bundle on github! isn't that helpful? Commented Aug 12, 2012 at 21:18
  • But that bundle is for the TextMate not the Sublime Editor! right? Commented Aug 12, 2012 at 21:28
  • @Raminson this said it was ok [youtube.com/… Commented Aug 12, 2012 at 21:30

2 Answers 2

13

first add Package Control to Sublime Text. This is accessed via the ctrl+` shortcut. Once open, paste the code from here into the console and hit Enter.

Go to Preferences > Package Control > from that list click on Package Control Install Package then search for jQuery. This will install jQuery.

Now, if you want autocompletion for jQuery follow these steps:

  1. Domnload this: package from github
  2. Extract the content in a place you can access it quickly, look for the file “AndyjQuery.sublime-completions”.
  3. Not sure if it will work just placing the file with the current name, so I renamed it as “jQuery.sublime-completions”
  4. Place this file in the folder jQuery from the location that opens when you go to Preferences - Browse Packages

if you want to use autocompletion when pressing the dot: Go to Preferences - Settings User and add this

"auto_complete_triggers": [ {"selector": "source.js", "characters": "."} ],

Sign up to request clarification or add additional context in comments.

Comments

4

Sublime Text 2 uses JavaScript syntax for supporting jQuery. In looking at the Github repo you tried, I'm assuming you're wanting some sort of a snippet library. I'd recommend this instead: https://github.com/aaronpowell/sublime-jquery-snippets and/or https://github.com/SublimeText/jQuery.

To clarify something else for you, adding:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

Adds the jQuery library to your HTML page so you can use its methods and functions. It doesn't add it to Sublime Text 2, but nonetheless it is necessary for the aforementioned reason.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.