最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Adding jQuery to sublime text 2 - Stack Overflow

programmeradmin4浏览0评论

I am new to jQuery world, and only today started using sublime text 2. Therefore, I am not aware of what packages I have to download and how to download. So, I would kindly request if anyone know how do I add jQuery to use it in my sublime text 2 editor. It will be great if you can give me a step by step instructions, like I said I am new to this. Also, how to get list of selections for jQuery.

Any help would be greatly appreciate it. Thanks :]

I am new to jQuery world, and only today started using sublime text 2. Therefore, I am not aware of what packages I have to download and how to download. So, I would kindly request if anyone know how do I add jQuery to use it in my sublime text 2 editor. It will be great if you can give me a step by step instructions, like I said I am new to this. Also, how to get list of selections for jQuery.

Any help would be greatly appreciate it. Thanks :]

Share Improve this question asked Mar 7, 2013 at 0:32 user123user123 974 silver badges12 bronze badges 9
  • you don't have to add jquery to sublime, you just have to include it in your page ie: <script src="path/to/jquery.js"></script>. Before even adding packages to Sublime, it is remended to use Sublime Package Control – alexdmejias Commented Mar 7, 2013 at 0:34
  • @alme1304 u sure? because it doesnt work. I did have a link – user123 Commented Mar 7, 2013 at 0:37
  • Easy like this: youtube./watch?v=JcAN4D1QV6o – Roko C. Buljan Commented Mar 7, 2013 at 0:38
  • positive. How do you know it does not work? – alexdmejias Commented Mar 7, 2013 at 0:38
  • @alme1304 because I have made a jQuery within sublime and try to run it but it doesnt work – user123 Commented Mar 7, 2013 at 0:40
 |  Show 4 more ments

2 Answers 2

Reset to default 4

jQuery is a JS library. To use it you need to include it in your document like:

<script src="http://ajax.googleapis./ajax/libs/jquery/1/jquery.min.js"></script>

Than you'll be able to manipulate your DOM elements/events doing crazy stuff like this:

<script>
    $(function(){
        $('body').prepend('HELLO EVERYONE!');
    });
</script>

or like

this demo

To help you in your work Sublime has a possibility to easily include that jQuery library by creating a shortcut snippet, I'll show you how:

Tools > New Snippet...

<snippet>
<content><![CDATA[
<script src="http://ajax.googleapis./ajax/libs/jquery/1/jquery.min.js"></script>
]]></content>
<tabTrigger>jquery</tabTrigger> <!-- the text that using [Tab] will paste the snippet -->
</snippet>

File > Save As...
(Under Documents And Settings/yourUserName/Application Data/Sublime Text 2/Packages/User/ )

jquery.sublime-snippet

Restart Sublime type jquery + hit your TAB key and the jQuery library snippet will be included in your document.

The same way you can create your own snippets that you use over and over for example like

$(function(){

});

var intv = setInterval(function(){

}, 1000 );

Sublime Text 2 is just an editor, you don't need to use the packages, snippets, etc. to use jQuery. In the HTML file where you want to use jQuery, you need to add a script tag that points to where the jQuery framework lives (this can either be a local path to where you placed jQuery, or a url of where jQuery resides on the internet).

For example:

<script src="http://ajax.googleapis./ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
    jQuery(function(){
        // your code goes here, you can use jQuery at this point
    });
</script>

As for a list of "selections" that really depends on the HTML markup you use. At this point, I can only remend you read the jQuery documentation. Here's a link to their learning center: http://learn.jquery./

发布评论

评论列表(0)

  1. 暂无评论