开发者

Why doesn't this javascript string code work in internet explorer 7?

开发者 https://www.devze.com 2023-04-06 00:21 出处:网络
I have the following code that works fine in IE8, firefox, chrome but not in IE7 Can someone please explain why this code below doesn\'t work in IE7 ?

I have the following code that works fine in IE8, firefox, chrome but not in IE7

Can someone please explain why this code below doesn't work in IE7 ?

  var myString = $(this).attr("id");
  var nextStep = myString [myString.length - 1];

basically, IE7 doesn't seem to understand this line:

   myString [myString.length -开发者_高级运维 1]

In this case myString is just a regular string that i am parsing out from the id of a div.


IE7 does not recognize indexing a string in that way. You need to use myString.charAt(myString.length - 1).

Array-like indexing of a string was added to ECMAScript 5, which was released well after IE7 was. More info

0

精彩评论

暂无评论...
验证码 换一张
取 消