开发者

document.getElementsByTagName doesnt word in IE when HTML loaded using Ajax

开发者 https://www.devze.com 2023-01-23 00:26 出处:网络
when loading content via ajax requests, If the response is: <div id=\"container\"> <a href=\"http://ww开发者_运维百科w.google.com\">To Google</a>

when loading content via ajax requests, If the response is:

<div id="container">
    <a href="http://ww开发者_运维百科w.google.com">To Google</a>
    <a href="http://www.yahoo.com">To Yahoo</a>
    <a href="http://www.digg.com">To Digg</a>
</div>

With the jquery loaded, and after content loading, i call a function that do the following:

<script type="text/javascript">
var hrefs = "";
var texts = "";
$('#container').find('A').each(function(){
    hrefs += ", " + $(this).attr('href');
    texts += ", " + $(this).html();
});
</script>

FF and Safari works fine and gain access to the links loaded. IE sucks so bad; it behaves like they don't exist.

Any help would be so much appreciated.

Barry;


  1. How do you ensure you call the method only after the DOM has been loaded? With $(document).ready?
  2. Try using lowercase (though HTML is case insensitive) and doing find('a') or using children('a')
0

精彩评论

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