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>

3 comments:

Robert F. Crocker said...

You can read the related blog entry at responsive web development

for IT the 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

Post a Comment