2

伙计,我只是不明白。我有四组配对链接,通过将鼠标悬停在另一组上。我让它在 jQuery 中工作,但是当我添加 Cufon 时它不是骰子。这是JQ脚本:

     <script type="text/javascript">
    jQuery(document).ready(function() {

      var doubleHighlight = function(element1, element2, class) {
        element1.hover(
          function() {
            element2.addClass(class);
          },
          function() {
            element2.removeClass(class);
          }
        );

        element2.hover(
          function() {
            element1.addClass(class);
          },
          function() {
            element1.removeClass(class);
          }
        );
      };
      doubleHighlight(jQuery("#abouttop"), jQuery("#aboutbottom"), "highlight_about");
      doubleHighlight(jQuery("#worktop"), jQuery("#workbottom"), "highlight_work");
      doubleHighlight(jQuery("#blogtop"), jQuery("#blogbottom"), "highlight_blog");
      doubleHighlight(jQuery("#contacttop"), jQuery("#contactbottom"), "highlight_contact");
    });
  </script>

这是 Cufon 的部分:

 <script src="cufon-yui.js" type="text/javascript"></script>
<script src="gothamxlight_300-gothamxlight_300.font.js" type="text/javascript">    </script>
<script src="gothamlight_300-gothamlight_500.font.js" type="text/javascript"></script>
        <script type="text/javascript">
           Cufon.replace('#type', { fontFamily: 'gothamxlight', hover: true});
            Cufon.replace('#smalltype', { fontFamily: 'gothamlight', hover: true});
            Cufon.replace('#nav', { fontFamily: 'gothamlight', hover: true});
        </script>

有任何想法吗?也许Cufon如何呈现文本?是否需要刷新?我在这里抓住稻草。

4

2 回答 2

0

是Cufon 不工作还是Cufon 破坏了你的doubleHighlight 的问题?

在发现大多数与 JQuery 相关的 Cufon 问题都归结为调用所有内容的顺序之前,我实际上自杀了。我很难在文档中找到他们对此的解释,就像去年 9 月我发现时一样,所以我担心我现在无法引用我的答案,我必须回去工作。基本上,Cufon 喜欢排在第一位,而 JQuery 通常乐于使用霰弹枪。例如;

这是或可能是坏的:

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="cufon-yui.js"></script>

<script type="text/javascript">
    your.jQueryKungFu(function() {
    };
</script>

<script type="text/javascript">
    cufon.replace('h1');
</script>

这很好:

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="cufon-yui.js"></script>

<script type="text/javascript">
    cufon.replace('h1');
</script>

<script type="text/javascript">
    your.jQueryKungFu(function() {
    };
</script>

请注意区别,第二次围绕 cufon 是在 jquery 函数之前处理的。

这个解决方案为我服务,因为我已经用 JQuery 运行了,Cufon 拒绝替换任何东西。我不确定您的问题是否来自同一学校的问题...

于 2010-03-05T16:39:47.047 回答
0

您需要调用函数 Cufon.refresh(); 事件发生后。 https://github.com/sorccu/cufon/wiki/API 我遇到了同样的问题,这种方法对我有用。

于 2012-05-28T10:13:41.367 回答