[英]Accordion not working in IE8 but works in others, why?
I am working on an accordion content page which will show a section open on page load by adding anchor type number to the end of the url string. 我正在开发一个手风琴内容页面,该页面将通过在URL字符串的末尾添加锚点类型号来显示在页面加载时打开的部分。 Such as the following: site/accordion_page.html#2 如以下内容:site / accordion_page.html#2
It works well in Firefox and Chrome but Internet Explorer 8 is not showing any of the accordion functionality. 它在Firefox和Chrome中运行良好,但是Internet Explorer 8没有显示任何手风琴功能。 I have included a jsfiddle here: http://jsfiddle.net/w4v34/1/ 我在这里包括了一个jsfiddle: http : //jsfiddle.net/w4v34/1/
Or please see my code below as well, thank you for assistance, Attila 或也请参阅下面的代码,感谢您的协助,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
Fix : 解决:
if (!window.console){ console = {log: function() {}} }; // works perfectly on IE8,chrome and FF
Updated Fiddle : 更新的小提琴:
Reference : 参考:
@OP pls try to search your problems/bugs before posting. @OP请尝试在发布之前搜索您的问题/错误。 thanks 谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.