preventDefault Help

preventDefault Help

Hi totally new to jquery, 

im having trouble controlling which class preventDefault is applied to.

  1. $(".main-cat > a").click(function (event) {

  2. if($('.main-cat > div:has(.sub-cat)')){

  3. event.preventDefault();
  4. }

  5. else{
  6. alert("sub cat does not exists");
  7. }

});

The problem is it is also working on a .main-cat which doesnt have a child class .sub-cat.

Any help with this is greatly appreciated.
Thanks