【问题标题】:Why does $('someObject').attr("id")[0] not work in IE?为什么 $('someObject').attr("id")[0] 在 IE 中不起作用?
【发布时间】:2009-02-05 14:36:28
【问题描述】:

以下 jquery 代码在 firefox 中有效,但在 IE 中返回 undefined:

$('someObject').attr("id")[0]

为什么会这样?

【问题讨论】:

    标签: jquery


    【解决方案1】:

    试试

    $('someObject').attr("id").charAt(0)
    

    Internet Explorer 中的字符串不支持 [] 索引器运算符。 string::charAt() 是正确的使用方法。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-09-21
      • 2013-09-07
      • 2022-11-26
      • 1970-01-01
      • 2011-11-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多