繁体   English   中英

使用jQuery高亮效果时window.name出现奇怪问题

[英]Strange issue on window.name when using jQuery highlight effect

我经常在某些表数据(td)单元格上使用jQuery高亮效果。 我刚刚意识到,当我使用此效果时,突出显示效果完成后,window.name值会神奇地更改“ data-ec”值。 此行为给我带来了一些问题,因为我需要检查以前设置的window.name。

我正在使用以下代码:

<html>
<head>
    <script src='jquery-1.6.min.js' type="text/javascript"></script> 
    <script src='jquery-ui-1.8.12.custom.min.js' type="text/javascript"></script> 

    <script type="text/javascript">

        function PlayIssue() {
            //Set Window Name
            window.name = 'myWindowName';
            // Get RIGHT window name
            alert(window.name); // popup shows "myWindowName" as window name

            //Play jQuery Effect on TD cell
            var myCell = $("#TableID tr[id='row_ID'] td:nth-child(1)");
            myCell.effect("highlight", { color: '#FFA500' }, 8000);

            //get WRONG window name
            alert(window.name);  // popup shows "data-ec" as window name
        }
     </script>
</head>
<body>
    <table id="TableID" border="1">
        <tr id="row_ID">
            <td>cell 1</td>
            <td>cell 2</td>
        </tr>
    </table>

    <script type="text/javascript">

        //Call JS Function to play issue
        PlayIssue();
     </script>
</body>
</html>

您对此行为有任何想法吗? 此问题在IE 9/10上发生(仅尝试过这些问题),但在Firefox和Chrome中不发生。

非常感谢。

我用“动画”功能代替了“效果”功能。

我使用了以下功能:

function flashColor(obj) {
    if (obj.length) {
        var originalColor = obj.css('backgroundColor');
        obj.animate({ backgroundColor: '#FFA500' }, 1000).delay(700).animate({ backgroundColor: originalColor }, 1000);
    }
}

暂无
暂无

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

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