Create tabs in jQuery - Without any plugin (10 lines of code)

Discussion in 'JavaScript' started by stitchapps, Aug 21, 2013.

  1. #1
    [​IMG]
    Using tabs on a website is a common practice these days. Still, most of us make use of jquery plugins to activate them. While there is no issue with that, but how about using tabs with less than 10 lines of jquery code? Hard to believe? Let’s see how we can do that.

    Check out the tutorial at: http://www.akshitsethi.me/perfect-tabs-using-jquery-no-plugin/

    I would love to know your comments on this guys. Also, which tutorial you would like to see next?
     
    stitchapps, Aug 21, 2013 IP
  2. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #2
    Given that by itself jQuery is HALF the filesize ideal I have for an ENTIRE page template (HTML+CSS+SCRIPTS+IMAGES) ten lines of jquery bloat isn't exactly gonna blow my skirt up... particularly since what you are talking about should be a simple matter of class swaps.

    Though generally speaking, given what inaccessible broken crap scripted tabs are on a website, we're not exactly talking something I'd be encouraging developers to do. It's just replicating frameset-style behavior, and those were deprecated for a REASON! (Though there's a lot of 'gee ain't it neat" bullshit people add to websites with javascript for no good reason)

    That said, it would be far more interesting if you let CSS do the heavy lifting (show/hide/fade) and you just added a self-attaching class-swap mechanism... without the fat bloated steaming pile of halfwit manure known as jQuery involved. Doubt it would pass more than a few K. toss it in an anonymous function (or even self-restricting class) and it could be pretty-well isolated from other scripts.
     
    deathshadow, Aug 22, 2013 IP