问题
I'm editing the "Zen" theme in Drupal 7. And that's the problem:
(function ($, Drupal, window, document, undefined) {
alert("xuy");
$("#navigation ul.links li").hover(function() {
alert("xuy");
});
The first alert is working well, but there is no alert on hover. I've got this class in CSS. Even
$("a").hover(function() {
alert("xuy");
});
Didn't work.
回答1:
Your code looks a little funky to me. Shouldn't you be using drupal behaviors in drupal 7? (yes you should).
Drupal.behaviors.mybehavior = function(context, settings){
$('#navigation ul.links li').hover(function() {
alert('xuy');
});
};
回答2:
you should determine $ like
(function($) {
Drupal.behaviors.mybehavior = {
attach: function(context, settings){
//you code goes here
//$ will work inside this function
}
};
})(jQuery);
来源:https://stackoverflow.com/questions/14503814/using-jquery-with-css-in-drupal-7-zen-theme