Skip to main content
Reformat the sentence.
Source Link
Jimmy Ko
  • 2.9k
  • 1
  • 12
  • 20

You need to wrap your JS code with Drupal behaviors, which can ensure your JS run after all required DOM elements in page are ready.

(function ($) {
  Drupal.behaviors.exampleModule = {
    attach: function (context, settings) {
      // Code to be run on page load, and
      // on ajax load added here
    }
  };
}(jQuery));

Also, you are not sure how to know if the jQuery is working. You can add console.log to check if jQuery successfully readoutput the required elementjQuery object in console.

var obj = jQuery( ".highcharts-input-group" );
console.log(obj);

You need to wrap your JS code with Drupal behaviors, which can ensure your JS run after all required DOM elements in page are ready.

(function ($) {
  Drupal.behaviors.exampleModule = {
    attach: function (context, settings) {
      // Code to be run on page load, and
      // on ajax load added here
    }
  };
}(jQuery));

You can add console.log to check if jQuery successfully read the required element.

var obj = jQuery( ".highcharts-input-group" );
console.log(obj);

You need to wrap your JS code with Drupal behaviors, which can ensure your JS run after all required DOM elements in page are ready.

(function ($) {
  Drupal.behaviors.exampleModule = {
    attach: function (context, settings) {
      // Code to be run on page load, and
      // on ajax load added here
    }
  };
}(jQuery));

Also, you are not sure how to know if the jQuery is working. You can add console.log to output the jQuery object in console.

var obj = jQuery( ".highcharts-input-group" );
console.log(obj);
Source Link
Jimmy Ko
  • 2.9k
  • 1
  • 12
  • 20

You need to wrap your JS code with Drupal behaviors, which can ensure your JS run after all required DOM elements in page are ready.

(function ($) {
  Drupal.behaviors.exampleModule = {
    attach: function (context, settings) {
      // Code to be run on page load, and
      // on ajax load added here
    }
  };
}(jQuery));

You can add console.log to check if jQuery successfully read the required element.

var obj = jQuery( ".highcharts-input-group" );
console.log(obj);