JQuery脚本,适用于Firefox,而不是在IE, Chrome
JQuery Script, Works in Firefox, not in IE, Chrome
我有下面的脚本,滑动一个容器向下和另一个向上,反之亦然,这取决于关闭/启用变量的条件。
该脚本在firefox中工作良好,但在IE和Chrome中,它只是不工作:(
谁能给点建议?
多谢!脚本如下:
(OCH变量接受通过ajax加载元素的容器的高度,因此它知道何时再次打开它打开多少px -这是最好的方式吗?)
$(document).ready(function()
{
//Grab the height of the container after its loaded with all the calls in...
var och = $('#calls').height();
//Are we allowed to close this panel yet?
var enabled = false;
//is the panel closed or not?
var closed = false;
$(".survey-description").click(function () {
if (enabled == true) {
if (closed == false) {
$(this).closest("#calls").stop().animate({"height": "44px"}, "fast");
closed = true;
}
else {
$(this).closest("#calls").stop().animate({"height": och}, "medium");
closed = false;
}
}
});
$(".linktoCall").click(function () {
if (closed == false) {
//Now we can toggle the top panel...
enabled = true;
$(this).closest("#calls").stop().animate({"height": "44px"}, "fast");
closed = true;
}
});
});
编辑这里是渲染元素的一些html。
<div id="survey-description"></div>
<div id="calls">
<div>
<p onclick="showCall('tgkn5xabgnivkaf');" id="notstarted" class="linktoCall">59677 tgkn5xabgnivkaf<br>NOT STARTED - SAVED</p>
</div>
</div>
<div id="aCall">
</div>
看一下HTML片段,我猜应该是
<div class="survey-description"></div>
,因为选择器$('.survey-description')
指向的是一个类,而不是一个id。
这主要是一个快速的猜测,因为我不知道问题中的html结构,也没有时间检查其余的,但是如果有冲突的元素id(例如两个id为"calls"的元素),不同的浏览器将表现不同。检查一下,确保这不是问题。
(另外,在比较中使用===而不是==)
如果你的HTML代码无效,它可能无法工作…我敢打赌你没有关闭div之类的…
你可以在这里查看你的页面:http://validator.w3.org/
还请删除测试
中的"px"值animate({"height": "xxpx"} ...
让它
animate({"height": 25}...
相关文章:
- IE/Chrome中未定义的函数,但Firefox中没有
- 滚动在Chrome中有效,但在Firefox或IE中无效
- CKeditor预览插件.js,为Chrome和IE进行编辑.因为它拒绝CSS样式
- 如何编写在Chrome和IE中正常工作的JavaScript
- Javascript/AAJAX在Opera中不起作用,在FF/IE/Chrome中完美工作
- JavaScript可以在IE+Chrome中使用,但不能在FF中使用
- 在 Java 中使用 IE/Chrome HTML 渲染器或使用 JavaScript 存储文件
- Javascript - 附加到文本区域值 - IE Chrome 和 Firefox
- Src 更改在 Firefox 中工作,而不是在 IE/Chrome 中
- HTML5游戏-工作在IE, Chrome.在FireFox中失败…直到我导航到一个.mp3文件…然后它才工作
- JQuery脚本,适用于Firefox,而不是在IE, Chrome
- jquery不工作在IE, Chrome,工作在FF
- 创建CSV并打开JS不工作在IE, Chrome
- OpenLayers 3旋转示例在Win32触摸设备上的IE/Chrome嵌入式WebBrowser控件中表现不同
- preventDefault()对一个多选择,不同的行为在Firefox - IE - Chrome
- Js工作在IE, Chrome,但不是Firefox
- Ie /chrome检查器导致重画
- 展开嵌套无序列表和水平显示在IE/Chrome/FF
- Firefox与IE/Chrome中的事件处理程序
- Firefox将文本叠加在错误的位置,而不是在Firefox中工作(在IE, Chrome和safari中很好)