3
Fexell
6y

We have a custom made CMS, where you can use templates (previous designs). Most of the time I see these templates with Javascript/jQuery that looks like this...
Edit: There is an extra $ in front of the first (function($). So like this: $(function($)

Comments
  • 3
    (Function(){ // this waits for the document to be ready

    $(document).ready // is fucking useless inside the other one

    <script> // at bottom of page is waiting for the dom to be ready anyway

    Like wtf, how ready does this DOM need to be 😂
  • 1
    @norman70688 The if statement is not needed at all. You can provide logic as a second parameter. Like this: $(".some-div").css({color: #fff}, $(window).scrollTop > 100);
  • 0
    I use
    jQuery(function($){ ... }
    as the sole wrapper. Should suffice every need.
  • 1
    @C0D4 My thought exactly.
  • 0
    @norman70688 My bad. Confused css with toggleclass there. Still, using a class toggle would be much more efficient.
  • 0
    I prefer using a toggle class as well. It's more lightweight and it's more clean/stable when you need some transitions.
Add Comment