Skip to main content
formatting mostly
Source Link
Mołot
  • 21.9k
  • 8
  • 59
  • 112

This is the right & simple way to include any JS file in Drupal 7.

  1. Create a folder named i.e. js, inside your module folder.
  2. Inside that folder place (modulename).js file.

Note: Drupal JS code has a specific format as follows:

    (function ($) {
      $(document).ready(function(){
        alert("Hello world!");  //here we can add our JS code
      });
    })(jQuery);
  1. Open (modulename).info file & add:

    scripts[] = js/(modulename).js

  2. Clear Cache & Run.

This is the right & simple way to include any JS file in Drupal 7.

  1. Create a folder named i.e. js, inside your module folder.
  2. Inside that folder place (modulename).js file.

Note: Drupal JS code has a specific format as follows:

(function ($) {
  $(document).ready(function(){
    alert("Hello world!");  //here we can add our JS code
  });
})(jQuery);
  1. Open (modulename).info file & add:

    scripts[] = js/(modulename).js

  2. Clear Cache & Run.

This is the right & simple way to include any JS file in Drupal 7.

  1. Create a folder named i.e. js, inside your module folder.
  2. Inside that folder place (modulename).js file.

Note: Drupal JS code has a specific format as follows:

    (function ($) {
      $(document).ready(function(){
        alert("Hello world!");  //here we can add our JS code
      });
    })(jQuery);
  1. Open (modulename).info file & add:

    scripts[] = js/(modulename).js

  2. Clear Cache & Run.

This is the right & simple way to include any JS file in drupalDrupal 7.

  1. Create a folder named i.e. js, inside your module folder.

  2. Inside them “(modulename).js” file is there.

  3. Below JS code in drupal have some format. Below is the format to add JS.

    (function ($) { $(document).ready(function(){ alert("Hello world!"); //here we can add our JS code }); })(jQuery);

  4. Open “(modulename).info” file & add

    scripts[] = js/(modulename).js

    Create a folder named i.e. js, inside your module folder.
  5. Clear Cache & Run.

    Inside that folder place (modulename).js file.

Note: Drupal JS code has a specific format as follows:

(function ($) {
  $(document).ready(function(){
    alert("Hello world!");  //here we can add our JS code
  });
})(jQuery);
  1. Open (modulename).info file & add:

    scripts[] = js/(modulename).js

  2. Clear Cache & Run.

This is the right & simple way to include any JS file in drupal 7.

  1. Create a folder named i.e. js, inside your module folder.

  2. Inside them “(modulename).js” file is there.

  3. Below JS code in drupal have some format. Below is the format to add JS.

    (function ($) { $(document).ready(function(){ alert("Hello world!"); //here we can add our JS code }); })(jQuery);

  4. Open “(modulename).info” file & add

    scripts[] = js/(modulename).js

  5. Clear Cache & Run.

This is the right & simple way to include any JS file in Drupal 7.

  1. Create a folder named i.e. js, inside your module folder.
  2. Inside that folder place (modulename).js file.

Note: Drupal JS code has a specific format as follows:

(function ($) {
  $(document).ready(function(){
    alert("Hello world!");  //here we can add our JS code
  });
})(jQuery);
  1. Open (modulename).info file & add:

    scripts[] = js/(modulename).js

  2. Clear Cache & Run.

Source Link
Nishant
  • 2.3k
  • 3
  • 21
  • 37

This is the right & simple way to include any JS file in drupal 7.

  1. Create a folder named i.e. js, inside your module folder.

  2. Inside them “(modulename).js” file is there.

  3. Below JS code in drupal have some format. Below is the format to add JS.

    (function ($) { $(document).ready(function(){ alert("Hello world!"); //here we can add our JS code }); })(jQuery);

  4. Open “(modulename).info” file & add

    scripts[] = js/(modulename).js

  5. Clear Cache & Run.