JSLint - '$' was used before it was defined

Friday, September 14, 2012
I'm using JSLint to validate my JavaScript.  For no other reason, it keeps things consistent.  However, I get the below warning message when performing a $(document).ready(...) call:

'$' was used before it was defined

To get around this, I pass jQuery in, assign it to $, and set my JSLint options.  Below is an example usage:

<script type="text/javascript">
    /// <reference path="../../Scripts/jquery-1.7.2.js" />
    /*jslint browser: true*/

    (function ($) {
        "use strict";
        /*global jQuery, document*/
           
        $(document).ready(function () {
            $('#RequiredFieldIndicator').show();
        });
    }(jQuery));
</script>

10 comments:

Robert said...

You can read the related blog entry at responsive web development

for ict 99 said...

JSLint to validate my JavaScript Javascript Training pass jQuery in, assign it to $, and set my JSLint options. Javascript Training in Chennai warning message when performing a $(document).ready(...) call Advanced Javascript Course

historypak said...

Your website is really cool and this is a great inspiring article. http://embossitworld.com/web-designing/ | website redesigning | Cms web design | E-commerce Web design | wordpress web design service | Responsive web design | Html5 Development

Softiconic said...

After a long time, I read a very beautiful and very important article that I enjoyed reading. I have found that this article has many important points, I sincerely thank the admin of this website for sharing it. Best wordpress web design agency service provider.

Joe Apps said...

This is very educational content and written well for a change. It's nice to see that some people still understand how to write a quality post.! best managed it support service provider.

Jalen Legros said...

After a long time, I read a very beautiful and very important article that I enjoyed reading. I have found that this article has many important points, I sincerely thank the admin of this website for sharing it. Best small business it support services near me service provider.

Norris Evans said...

Thank you so much for sharing this blog with us. It provides a collection of useful information. You obviously put a lot of effort into it! Best python string methods service provider.

Jobz Guru said...

It’s great to come across a blog every once in a while that isn’t the same out of date rehashed material. Fantastic read. Best govt jobs in pakistan for teachers service provider.

Unknown said...

Great Article IoT Projects for Students

Deep Learning Projects for Final Year

JavaScript Training in Chennai

JavaScript Training in Chennai

The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

Norris Evans said...



After a long time, I read a very beautiful and very important article that I enjoyed reading. I have found that this article has many important points, I sincerely thank the admin of this website for sharing it. python string methods

Post a Comment