Hi totally new to jquery,
im having trouble controlling which class preventDefault is applied to.
- $(".main-cat > a").click(function (event) {
- if($('.main-cat > div:has(.sub-cat)')){
- event.preventDefault();
-
- }
- else{
- alert("sub cat does not exists");
- }
});
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