繁体   English   中英

手风琴不能在IE8中工作,而可以在其他人中工作,为什么?

[英]Accordion not working in IE8 but works in others, why?

我正在开发一个手风琴内容页面,该页面将通过在URL字符串的末尾添加锚点类型号来显示在页面加载时打开的部分。 如以下内容:site / accordion_page.html#2

它在Firefox和Chrome中运行良好,但是Internet Explorer 8没有显示任何手风琴功能。 我在这里包括了一个jsfiddle: http : //jsfiddle.net/w4v34/1/

或也请参阅下面的代码,感谢您的协助,Attila

$(document).ready(function() {

  var allPanels = $('.accordion > dd').hide();
  var allControlIcons = $('.accordion > span');

  var urlString = $(location).attr('hash').slice(1);
  var startN = (parseInt(urlString))-1; // minus one to make it zero based for the eq: numbering
  console.log(startN);

  $('.accordion dd:eq('+startN+')').addClass('active').show();
  $('.accordion dt:eq('+startN+')').find('span').
  empty().html('–');


  $('.accordion > dt > a').click(function() {
      $this = $(this);
      $target =  $this.parent().next();
      $control = $this.find('span');

      $('.accordion').find('span').empty().html('+');
      $this.closest('dt').find('span').empty().html('–');

      if(!$target.hasClass('active')){

         allPanels.removeClass('active').slideUp("fast");
         $target.addClass('active').slideDown("fast");

      } 

    return false;
  });
});
console.log(startN);  // this is where you get your error on IE8

解决:

if (!window.console){ console = {log: function() {}} }; // works perfectly on IE8,chrome and FF

更新的小提琴:

点击

参考:

这里

@OP请尝试在发布之前搜索您的问题/错误。 谢谢

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM