【发布时间】:2011-04-06 03:42:00
【问题描述】:
有点被这个难住了,所以我希望你们能提供帮助。
看起来我可能发现了一个与 IE 相关的 jQuery 错误。创建了一个小测试(包括在这里),我可以欺骗这个问题。在 Firefox 和 Chrome 中运行良好,在 IE8-9 中失败。
问题是在事件回调中发生更新时,DIV“podcastStatus”没有在正确的时刻更新。您可以使用 IE 工具和 Firebug 并在我在代码中注释的位置设置断点来在本地对其进行测试。
步骤:
- 在 Firebug 和 IE 中设置断点
- 根据我在代码中的 cmets 开发工具
- 点击“下一个”或“上一个”
- DIV 中的文本应根据您单击的按钮更改为“下一个”或“上一个”
- DIV 中的文本随后应恢复为“正在播放...”
我认为它与 innerHTML 相关,但我尝试了 innerHTML DIV 包装技巧和无骰子。
注意:我使用了 .text() 和 .html() 都没有分辨率。
这是测试用例:
<body>
<style type="text/css">
#podcastStatus {
background-color: ButtonHighlight;
font-size: 120pt;
font-weight: bolder;
color: Black;
margin: 0 auto;
text-align: center;
position:absolute; top:0; bottom:0; left:0; right:0;
margin:auto; height:200px; width:100%;
z-index: 100;
}
</style>
<div id="podcastStatus">Playing...</div>
<div id="targetBtns">
<input type="button" name="prev" id="prev" value="Prev"/>
<input type="button" name="next" id="next" value="Next"/>
</div>
<script>
function onButtonClicked(e) {
switch (e.target.defaultValue) {
case "Next":
// Use IE tools or Firebug...
//Set breakpoint here. Immediate after this executes, DIV text should be updated to "Prev"....
$('#podcastStatus').html("Prev").show();
break;
case "Prev":
// Use IE tools or Firebug...
//Set breakpoint here. Immediate after this executes, DIV text should be updated to "Next"....
$('#podcastStatus').html("Next").show();
break;
}
//Set breakpoint here. DIV should show either "Prev" or "Next" at this point...
playPause();
}
function playPause() {
$('#podcastStatus').text("Playing...").fadeIn('slow');
}
$( "#targetBtns" ).click( function(event) { onButtonClicked(event) } );
</script>
</body>
【问题讨论】:
-
哇,一开始我什至没有注意到提问者是谁——嗨,雷伊!今晚有一杯好水吗? ;)