.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/ を使用して共有しようとするとすぐに、インデックス カウントが適切に機能しなくなります。