Javascript slider questions

I have a slider script.

JS Code:

  <script>
    $(function(){
      $("#slides").slidesjs({
        start: 3,
        width: 940,
        height: 10
      });
    });
  </script>

Once the html or php is loaded, the slider starts, all is well.

Question1: No where in the page explicitly tells this function to load, how does it get loaded? Is it the $ sign in front of $(function() some kind of shorthand from jQuery for document .ready or something like that?

Question2: When I put an alert() right after $(function(){, the alert pops up with this message: function (a,b){return new m.fn.init(a,b)} What does it mean?

Code:

<script>
  var sf=6,
    $(function(sf){
      $("#slides").slidesjs({
        start: sf,
        width: 940,
        height: 10
      });
    });
  </script>

How to go about doing this?

Answers 1

  • A1 - yes, $(function(){}); is self executing function. It differs from .ready in that way, that .ready will be executed only when DOM is ready, while $(function(){}); will be executed as soon as this code is reached by parser.

    A2 not clear. alert() is not valid, because it need to have some content passed in. You can pass function name to and it will alert function description.


Related Articles