0

我正在研究在单击图像时显示/隐藏 div 并在页面加载时随机显示 div 的能力。我不太确定它为什么在测试区域(JSfiddle)中有效,但在我将它实施到站点时却不是。

这里是小提琴的链接:http: //jsfiddle.net/JmVUx/17/

这是我正在处理的网站的演示: http: //sjdunham.com/test/yzn/

我错过了什么吗?不太清楚两者之间可能有什么区别。我已经尝试删除对其他脚本的任何其他引用,但仍然没有成功。我在检查器的演示站点上看不到任何错误。在过去的 4 个小时里,我一直盯着这个,我不知道是什么导致了这个问题。

4

3 回答 3

3

您在网站上有其他<a>元素。使用$("a.control")代替,并使用.eq代替$($(...).get(x))

于 2012-07-27T19:07:10.107 回答
0

I've checked both of your codes and see that there's something smoothly different:

var randomIndex = Math.floor((Math.random() * 100) + 1)%2; // Site version
var randomIndex = Math.floor((Math.random() * 100)+ 1)%3;  // jsFiddle version

Check everything out again. Maybe you get the answer. It should be random with both implementations, but it may not be random enough. What I mean is: it can be resulting much of the same randomIndex, so you cannot check the difference when loading page.

于 2012-07-27T19:14:33.473 回答
0

您正在使用,并且在对正在使用的Cufon font任何更改后需要刷新以生效,因此在您的代码的最后添加此行,即domCufon fontCufon.refresh();

// other code
$('#' + field + '-gallery, #' + field + '-tag').fadeIn("slow");
Cufon.refresh(); // without this line your dom won't refresh (only for cufon font)

您的所有内容都p替换为cufon如下代码,因为Cufon.replace(...)

<p>
    <cufon class="cufon cufon-canvas" alt="In " style="width: 20px; height: 16px; ">
        <canvas width="33" height="16" style="width: 33px; height: 16px; top: 0px; left: 0px; "></canvas>
        <cufontext>In </cufontext>
    </cufon>
    <cufon class="cufon cufon-canvas" alt="today's " style="width: 65px; height: 16px; ">
        <canvas width="78" height="16" style="width: 78px; height: 16px; top: 0px; left: 0px; "></canvas>
       <cufontext>today's </cufontext>
   </cufon>
   ....
</p>

关于so​​的另一个答案

于 2012-07-27T19:20:56.810 回答