2010-03-01 61 views
2

男人,我只是不明白。我有四套配对的链接,其中一套在另一套上徘徊。我有它在jQuery中工作,但是当我添加Cufon时,它不是骰子。这里有JQ脚本:Cufon为什么不允许使用jQuery的addclass函数?

 <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> 

下面是对的Cufón部分:

<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如何渲染文本?是否需要刷新?我在这里抓着稻草。

+1

Cufon不会完全替换原始元素,或者至少添加全新的元素吗?那不就是说Cufon完成后,原始文本的事件处理程序是不相关的吗? – Pointy 2010-03-01 23:23:19

+0

我认为Pointy是对的,Cufon取代你的原始元素。我相信它调查CSS:悬停的东西(如果您将{hover:true}传递给'Cufon.replace'函数)并为其创建正确的元素,但浏览器不再将元素渲染为文本。所以添加修改文本呈现方式的CSS类没有任何作用。 – 2010-05-22 18:36:05

回答

0

Cufon不工作或Cufon打破你的双重高光的问题?

在发现与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> 

注意区别,周围的Cufón第二次是在jQuery函数之前处理。

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

相关问题