Call a function in JS file from drupal I have included a javascript in the module "myid" I've been developing in drupal by using this code:

function myid_init() {
    drupal_add_js(drupal_get_path("module", "myid") . "js/myid.js");   
}


This is my Javascript file "myid.js":

function myid_js_start(){
    alert("hello world");
}


Below is the code that creates a button that invokes an alert function:

$form['add_button'] = array(
    '#type' =&gt; 'button',
    '#value' =&gt; 'Take a picture',
    '#attributes' =&gt; array('onclick' =&gt; 'myid_js_start()'),    
);


I dont know where did I go wrong. The button shows up but doesn't fire any alert function. Can anyone help me with this?
Try to write JS in drupal way like this:

(function($) {

    Drupal.behaviors.xyzModule = {
        attach: function(context, settings) {


//            $('.test', context).click(function() {
//                $(this).next('ul').toggle('show');
//            });

//myid_js_start();
            function myid_js_start() {
                alert("hello world");
                //console.log(' Hello');
            }

        }
    };

})(jQuery);


For More info visit here