【发布时间】:2013-09-19 17:40:24
【问题描述】:
我对 .index() 有一个非常奇怪的问题。我一直在本地构建一些东西,一切正常。一旦我将代码放在 WAMP/MAMP 本地托管上,.index() 计数就会停止正常工作。
var prodCont = $(".disaCats"); prodCont.each(function(){ //Checking too see how Many products the category has var tempIndex = $(this).children(".cardContainer").index(); //If the there are more than 6 products show the dropdownArrow if(tempIndex > 5){ $(this).siblings(".disaHeading").children(".showMoreArrow").show(); });//end index calculation
我使用警报返回 tempIndex,它为每个项目返回 0。
我尝试使用 .index(this) 和 .children() 而不使用类选择器,但它做同样的事情。我开始认为这是 WAMP/MAMP 的问题。
非常感谢任何帮助。
编辑:此脚本通过 WAMP/MAMP 上的 localhost/ 运行良好,但一旦我尝试使用我的 ip 521.xxx.xxx/ 共享它,这就是索引计数停止正常工作的时候。
【问题讨论】:
-
WAMP 不能影响 javascript 的执行方式,javascript 是客户端。
标签: javascript jquery wamp mamp