"Object doesn't support the property or method"
クラスonChange
がVariationSelect
. _ ということで以下に絞り込みました。
$(".VariationSelect").change(function() {
// a bunch of irrelevant code
// get the index of this select
var index = $('.VariationSelect').index($(this)); //this is the line throwing the error in IE7
//some code that returns a block of data in json formatting
});
attr('disabled', 'disabled')
私の最初の考えは、 removeAttr も使用されたときに IE7 で以前に問題があったため、コードのセクションでしたが、それらの行を削除しても、エラーは同じままで、JS エラーの行/文字参照 (もちろん無意味です)は変わりません。では、IE7 が受け入れないコード ブロックが他にあるでしょうか。
編集:選択ボックスが変更された後にコードが実行されています。選択ボックスの HTML は次のようになります。
<div class="DetailRow">
<div class="Label">Some Label:</div>
<div class="Value">
<select name="variation[aNumberStartingAtOneAndIncrementingUpwards]" class="VariationSelect" id="VariationSelect" style="width: 180px;">
<option value="">-- Choose an option --</option>
{A bunch of options for this choice loaded by PHP}
</select>
</div>
</div>
name 要素には常にインデックスよりも 1 大きい数値が含まれていることがわかっているため、これを行う手っ取り早い方法は、次のように変更された要素から名前を取得することです。
var index = $(this).attr('name');
index = index.replace('variation[','');
index = index.replace(']','');
index = (index*1)-1;
インデックスを取得するためのより高速でより良い方法はありますか?