OnClick Event not Captured I was currently developing a module(myid) in Drupal. I made a button(#myid_registrar_button) that must alert whenever it is clicked. Below is my code:

myid.module file:

&lt;?php

    function myid_init() {
        //Jquery Library  
        drupal_add_js(drupal_get_path("module", "myid") . "/js/jquery-1.11.2.min.js");

        //Custom Javascript             
        drupal_add_js(drupal_get_path("module", "myid") . "/js/myid.js");   
    }

    function myid_menu()
    {  
        $items = array();

        $items['admin/settings/myid'] = array(
            'title' =&gt; 'myid Settings',
            'description' =&gt; 'Configuration options for the myid module',
            'page callback' =&gt; 'myid_admin_settings',
            'access callback ' =&gt; 'user_access',
            'access arguments' =&gt; array('administer site configuration'),
        );
        return $items;
    }

    function myid_admin_settings()
    {
        return drupal_get_form('myid_settings_form');
    }

    function myid_settings_form()
    {
        $form = array();
        $form['myid_registrar_button'] = array(
            '#type' =&gt; 'button',
            '#value' =&gt; '...',       
            '#attributes' =&gt; array(
                'id' =&gt; 'myid_registrar_button',         
            ), 
        ); 
        return $form;
    }


myid.js file

$(function(){
    $('#myid_registrar_button').on('click', function(e) {
        e.preventDefault(); 
        alert("Eww");             
    }); 
});


Whenever I click a button, it refreshes and doesnt alert something, which is supposedly will not refresh and will alert "Eww". It seems that the onclick event is not captured.The console throws no error. Where am I missing?
You shouldn't be adding JQuery like that.  It's automatically included in core, so you don't need to include it yourself.  To stay up with the latest JQuery version, install the jQuery Update module.

For your JS file, this should work:

(function ($) {
    Drupal.behaviors.myid.registrar_button = {
        attach: function (context, settings) {
            $('#myid_registrar_button').on('click', function(e) {
                e.preventDefault(); 
                alert("Eww");             
            }); 
        }
    };
})(jQuery);