2013-05-28 95 views
0

我現在正在發佈完整的代碼,請檢查並讓我知道我必須在此代碼中修改以解決此問題問題在IE:SCRIPT5007:無法獲取屬性'indexOf'的值:對象爲null或undefined.Please幫助解決此問題

var values = []; 
$("#tblitem #itm").each(function(a, b) 
{ 
values[a] = b.text; 
}); 

valuex [X]用於取ITEMNAME here.and下面我用它在的indexOf()的indexOf()工作良好之前我使用array.problem使用陣列之後發生。只在IE中。

var compare_value_oldd="$500"; 
var compare_value_neww=parseFloat(compare_value_oldd.replace(/[^0-9-.]/g,'')); 

for(var x in values) 
{ 

if (parseFloat(totalnumm.replace(/[^0-9-.]/g,'')) > compare_value_neww && values[x].indexOf("Custom") > -1) 


    { 

if ($.cookie('test_status1') != '2') 

{ 

       $('#element_to_pop_up1').bPopup({ 
        content: 'image', //'ajax', 'iframe' or 'image' 
        contentContainer: '.content', 
        loadUrl: 'coupon.jpg' 
       }); 


<!--cookie settings here--> 
<!--expire time of cookie is 30 days.you can change it as per your requirements--> 

      $.cookie('test_status1', '2', { expires: 30 }); 


} 

} 

} 

我在這一行發生錯誤。

**if (parseFloat(totalnumm.replace(/[^0-9-.]/g,'')) > compare_value_neww && values[x].indexOf("Custom") > -1)** 
+0

採取看看http://stackoverflow.com/questions/1744310/how-to-fix-array-indexof-in-javascript-for-ie-browsers – anderssonola

+0

因此值[x]爲空或未定義 –

+0

嗨soderslatt請讓我知道我必須添加jQuery.inArray(value,array [,fromIndex] )??? – honey

回答

0

你應該換元jQuery對象中:

var values = []; 
$("#tblitem #itm").each(function(a, b) 
{ 
    values[a] = $(b).text(); 
}); 

我不知道哪一種元素是「#itm」,你可以有使用$(b).html();$(b).val();

+0

烤我對jquery很陌生,所以請告訴我我在這裏需要修改..i將高度感謝 – honey

+0

要修改什麼?你讀過我的回答嗎? –

+0

我沒有讓你說「在jquery對象中包裝元素:」請 – honey

相關問題