开发者

jquery unexpected call to method or property access ie error

Friends need开发者_如何学Python help to resolve this issue.

(function($){

   $('*').each(function(){

if ($(this).children().length == 0) { 



          $(this).html($(this).html().replace(avidno,'<span id=avidlocal>AvidTrak Tracking Number</span>')); 

     } 



   });



})(jQuery)


Since the following line is what's giving you the error:

$(this).html($(this).html().replace(avidno,'<span id=avidlocal>AvidTrak Tracking Number</span>'));

you should break it up so that only one method is being called per line. This will allow you to further isolate the error. For example:

var obj = $(this);    
var currentHTML = obj.html();
var newHTML = currentHTML.replace(avidno,'<span id=avidlocal>AvidTrak Tracking Number</span>');

If the var currentHTML line is the issue, then $(this) is probably undefined for some reason. Or perhaps you need quotes around the id name "avidlocal". Hard to say, since this is an IE bug after all, and I don't see anything specific that I know doesn't work in IE.

As a final note, I would strongly advise your friend to find a better way to achieve what he's aiming. $('*').each will loop through every single element on the page. Does your friend really not have any way of producing HTML that allows the "avidno" text to be more easily replaced, i.e. more easily accessed via jQuery (through a class/id) than by looping through everything and checking if they have children nodes?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜