Attach behavior only to the file upload button I have a form with a managed_file field where I need to know when the upload button is clicked, and then perform an action. I decide to make it by attaching a behavior to my button but it also trigger when I click on the remove button. Here is my code:

Drupal.behaviors.mattButtons = {
    attach: function (context) {
    jQuery('input.form-submit', context).bind('mousedown', Drupal.matt.checkFile );
    }
};


Drupal.matt = Drupal.matt || {
    checkFile : function(){
        console.log("Hello");
        var url = jQuery('.file a').attr('href');
        console.log(url);
    }
};


Is there any way to only attch my behvior on the file upload button?
You can simply be more specific with your jQuery selector. For example, you could theme_file_managed_file to give your upload button it's own class and then change your jQuery('input.form-submit', context) line to include that class in the selector.

jQuery('input.my-upload-class', context)