SCRIPT5007:无法获取属性'indexOf'的值:object为null或undefined。请帮助解决此问题

时间:2013-05-28 09:30:02

标签: performance jquery-ui jquery bpopup

我现在正在发布完整代码请检查并告诉我在此代码中我必须修改的内容以解决IE中的这个问题:

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

valuex [x]用于获取itemname。在下面我在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 )**

1 个答案:

答案 0 :(得分:0)

你应该将元素包装在jquery对象中:

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

我不知道哪种元素是'#itm',您可能必须使用$(b).html();$(b).val();

相关问题