首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >IE8: jQuery附加不起作用

IE8: jQuery附加不起作用
EN

Stack Overflow用户
提问于 2014-01-04 06:59:24
回答 1查看 5.6K关注 0票数 2

jQuery附件对于所有现代浏览器都很好,但是对于ie8,它的工作并不完美。

有一个问题。我想附上超链接。它工作完美,但在IE中,它并不是附加超链接。

这是我的代码:

代码语言:javascript
复制
<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>

您可以检查这个jsbin是否为iE8,它没有附加超链接。需要帮助!

jsbin

EN

回答 1

Stack Overflow用户

发布于 2014-01-04 07:02:19

您在jQuery中遗漏了一个结束标记。

代码语言:javascript
复制
</i></a>

另外,IE11 (边缘模式)似乎会阻塞jquery(document).ready类型的调用。然而,更改为快捷方法$(function(){code});似乎工作得很好。下面的javascript已经过测试并确认可以与Chrome,IE8+一起工作。

代码语言:javascript
复制
$(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

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20918046

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档