By editor, 2 June, 2016 Question How to execute JS codes on selected Pages, using drupal body class ? Example : Execute JS only in the front page. This Script run whin the body tag contains class='front' (function ($) { $(document).ready(function () { if ($('body').hasClass('front')) { alert('Hello'); } }); })(jQuery); Tags Drupal 8 Drupal 7 JavaScript jQuery Drupal Behaviors - JavaScript and jQuery Comments You must have JavaScript enabled to use this form. Your name Subject Comment About text formats Text format Plain textBasic_html Plain text No HTML tags allowed. Lines and paragraphs break automatically. Web page addresses and email addresses turn into links automatically.
Comments