K
K
Kirill2016-12-03 23:39:32
Drupal
Kirill, 2016-12-03 23:39:32

Why jQuery might not work on Drupal7?

tell me pliz what could be the matter, the simplest code, it works on jsfiddle but on Drupal7, well, nothing.
the file with the script is loaded, jQuery itself too.

(function (jQuery) {
function anichange (objName) {
 if ( jQuery(objName).css('display') == 'none' ) {
 jQuery(objName).animate({height: 'show'}, 400);
 } else {
 jQuery(objName).animate({height: 'hide'}, 200);
 }
}
}) (jQuery);

<li><a href="#u" onclick="anichange('#vipad'); return false">Нажми</a></li>
      <div id="vipad">
        <h2>Контакты</h2>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
andead, 2016-12-04
@KirillSPB777

Because the anichange function is in the scope of the anonymous function and is not accessible outside. This won't work on jsfiddle either.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question