0

We are using event click to catch click on links and load content via ajax. But event happens also on right mouse and wheel clicks. How to process only left? confused

// jquery.coyod-engine-0.5.0.js
$(document).click(function(e){
        
        var t = $(e.target);            
        if(t.hasClass('aj'))
        {               
            
            e.stopPropagation();
            e.preventDefault();
            showContent(t.attr('href'));                            
            return false;               
        }
        
        return true;
        
    });
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Coyod
  • 2,656
  • 2
  • 18
  • 13

2 Answers2

3

Throw in a check at the start of you function which checks if the left button was used

//left == 0, middle == 1, right == 2
if (e.button != 0) return true;
else {
  //whatever
  return false;
}
jitter
  • 53,475
  • 11
  • 111
  • 124
2

Just add this at the begining of your callback:

if (e.button != 0) return true;
Guillaume Flandre
  • 8,936
  • 8
  • 46
  • 54