【发布时间】:2012-04-20 22:14:00
【问题描述】:
我有一个问题,为什么它在 IE 8 中工作
$(function() {
$('.title .hide').showContent();
});
$.fn.showContent = function() {
return this.each(function() {
var box = $(this);
var content = $(this).parent().next('.content');
box.toggle(function() {
content.slideUp(500);
$(this).css('background-position', 'right bottom');
}, function() {
content.slideDown(500);
$(this).css('background-position', 'right top');
});
});
};
这不起作用?
$(function() {
$('.title .hide.show').hideContent();
});
$.fn.hideContent = function() {
return this.each(function() {
var box = $(this);
var content = $(this).parent().next('.content');
box.toggle(function() {
content.slideDown(500);
$(this).css('background-position', 'right top');
}, function() {
content.slideUp(500);
$(this).css('background-position', 'right bottom');
});
});
};
我希望这两个选项工作,但我不知道为什么第二个在 IE 8 中不起作用,我希望有人能帮助我。
【问题讨论】:
-
这两个函数有可能互相干扰吗?您在调用
hideContent()的所有元素上调用showContent(),如果您使用唯一类识别元素会发生什么? -
不,我有 和 并将 js 更改为 .title .hide 和 .title .show但仍然没有运气......
-
你能创建一个jsFiddle问题的演示吗?
-
嗨,安东尼,这是一个小提琴jsfiddle.net/wyJXr,但这很好用。我认为它在我的代码中有所不同导致错误。
标签: jquery internet-explorer-8 hide show collapse