IE8:jQuery append 不起作用



jQuery append适用于所有现代浏览器,但对于ie8来说,它不能完美地工作。

有一个问题。 我想附加超链接.它运行良好,但在IE中它没有附加超链接。

这是我的代码:

<div id="recent-posts-2" class="sidebar_wrapper widget_recent_entries widget">                 
    <div class="sidebar_title clearfix">
        <h3 class="fl widget-title">Recent Posts</h3>
    </div>
    <ul class="news_ul clearfix">
        <li>
            <span class="post-date">June 3, 2013</span>
            <a href="http://domain.com/wood/china-conference-optional-tours/">China Conference &amp; optional tours</a>
        </li>
        <li>
            <span class="post-date">March 8, 2013</span>
            <a href="http://domain.com/wood/hello-world/">Russia: Forest Industry Competitiveness &amp; Export Outlook</a>
        </li>
        <li>
            <span class="post-date">March 1, 2012</span>
            <a href="http://domain.com/wood/u-s-moulding-market-supply-options-outlook-to-2017/">U.S. Moulding Market &amp; Supply Options: Outlook to 2017</a>
        </li>
    </ul>
</div>
<script>
    jQuery(function() {
        jQuery('.widget_recent_entries .sidebar_title').append('<a href="<?php echo site_url(); ?>/news" class="fr news_more">more <i class="fa fa-arrow-circle-right"></i></a>');

    });
</script>

您可以检查此 iE8 的 JSBIN 它没有附加超链接。 需要帮助。!

JSBIN

你在jQuery中缺少结束标签。

</i></a>

此外,IE11(边缘模式)似乎在jquery(document).ready类型调用中阻塞。 但是,更改为快捷方式方法似乎$(function(){code});就可以了。 下面的javascript已经过测试并确认可以与Chrome,IE8+一起使用。

$(function(){  
  $('.widget_recent_entries .sidebar_title').append('<a href="<?php echo site_url();?>/news" class="fr news_more">more <i class="fa fa-arrow-circle-right"></i></a>');
  });

最后,请记住,jQuery 2.X仅适用于IE9及更高版本(这不是这里的问题,而是对将来可能访问的人的友好提醒)。

http://jsbin.com/isAgEXAX/12/edit

最新更新