Results 1 to 2 of 2

Thread: .hasClass method and if statement

  1. #1
    Join Date
    Aug 2014

    .hasClass method and if statement

    Greetings all,please check this code: http://jsfiddle.net/RZpbK/1558/

    now what i understand from :
    if (!$target.hasClass('active') && $other.length > 0)
    is that:
    is always false,since $target already has class 'active' added by the previous function,if that's the case,how would this 'if statement' ever execute?

  2. #2
    Join Date
    Feb 2014
    Managua, Nicaragua
    var $target = $($(this).attr('href')),
    $other = $target.siblings('.active')

    var target point to the href attr of the link. eg "#target1"

    so, !$target.hasClass('active') is equal to jQuery('#target1').hasClass('active')

    the class is added to the panels next to the links, so in this way, every time that is clicked a link, the code assesses whether it has the class 'active' or not... but remember that assesses if the div.panel has the class, not the link...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center