【问题标题】:Trying to add a mouseover effect to this Javascript code尝试向此 Javascript 代码添加鼠标悬停效果
【发布时间】:2011-03-15 20:06:39
【问题描述】:

您好,我正在尝试向此代码添加鼠标悬停效果,但我没有成功,任何帮助都会很棒...我不确定您是否需要更多信息,但如果需要,我可以添加您需要的任何内容

我遇到的问题是,当我越过选项卡时,我可以单击文本并将其全部突出显示:(如果可以的话,在正常的鼠标悬停效果之后

谢谢

<script type="text/javascript"> 
function init(){
    var stretchers = document.getElementsByClassName('box');
    var toggles = document.getElementsByClassName('tab');
    var myAccordion = new fx.Accordion(
        toggles, stretchers, {opacity: false, height: true, duration: 600}
    );
    //hash functions
    var found = false;
    toggles.each(function(h3, i){
        var div = Element.find(h3, 'nextSibling');
            if (window.location.href.indexOf(h3.title) > 0) {
                myAccordion.showThisHideOpen(div);
                found = true;
            }
        });
        if (!found) myAccordion.showThisHideOpen(stretchers[0]);
}
</script>

【问题讨论】:

  • 看看mootools 中的mouseenter/mouseleave 的东西(假设你正在使用它)在旁注中,你也可以执行“var stretchers = $$('.box');”如果你确实在使用 moo
  • 嗨,我对 JS 的工作方式非常陌生,是的,在这个 zip 中,我发现了两个带有 moo 的文件,其中 moo.fx.js 和 moo.fx.pack.js。还有prototype.lite.js
  • 老实说,mootools 带有一个不错的手风琴组件,并且有相当不错的文档记录。如果对你有用的话,我会使用他们那里的任何东西(查看 mootools.net 上的更多文档)

标签: javascript tabs mouseover


【解决方案1】:

要在 jquery 中添加鼠标悬停效果,可以这样尝试:

$('#your id / .your class').bind('mouseover', function() {
    alert('hello world');//YOUR CODE HERE
});

我在您的代码中没有看到任何鼠标悬停事件,请检查 API here

【讨论】:

  • 我可以把它加到上面的 JS 中吗?
  • var div = Element.find 判断,他没有使用 jQuery - 所以不,那行不通。
猜你喜欢
  • 2018-02-06
  • 1970-01-01
  • 2020-08-16
  • 2013-08-31
  • 1970-01-01
  • 2013-11-23
  • 2016-04-26
  • 2013-05-06
  • 1970-01-01
相关资源
最近更新 更多