0

大家好,我对 IE10 和 chrome 有问题。扩展表格后,IE10 不会崩溃,对于 chrome,它会在它之间留下空白空间。它在 ie8、firefox 中工作。我已经尝试过 display:none 和 display: table-row ..但它只适用于 IE 10 ..

这是javascript代码

function loadSessionLogEvents(id) { 
        var visibility = $('eventTR' + id).style.visibility;
        if (visibility == 'collapse')
        {
            $('eventTR' + id).style.visibility = 'visible';
            var tURL = '<%=request.getContextPath()%>/home/Folder.action?listSessionLogEvents=&sessionLogId=' + id;
            new Ajax.Updater($('detailTR' + id), tURL, { 
                method: 'get',
                evalScripts: 'hidden'
            });
        } else {
            $('eventTR' + id).style.visibility = 'collapse';
        }
    }

所以我改变后的代码应该是这样的?

function loadSessionLogEvents(id) { 
        var visibility = $('#eventTR' + id).css('visibility');
        if (visibility == 'collapse')
        {
            $('eventTR' + id).css('visibility','');
            var tURL = '<%=request.getContextPath()%>/home/Folder.action?listSessionLogEvents=&sessionLogId=' + id;
            new Ajax.Updater($('detailTR' + id), tURL, { 
                method: 'get',
                evalScripts: 'hidden'
            });
        } else {
            $('eventTR' + id).css('visibility','collapse');
        }
    }

这是点击按钮功能

href="#" onclick="javascript:loadSessionLogEvents('${file.session.id}')">

4

1 回答 1

0

根据评论,这里有多个问题

  1. 您需要使用id-selector而不是元素选择eventTRdetailTR元素
  2. jQuery 包装器对象没有调用属性style,您需要使用.css()来获取和设置 css 值

尝试

function loadSessionLogEvents(id) { 
    var $tr = $('#eventTR' + id);
    var visibility = $tr.css('visibility')
    if (visibility == 'collapse') {
        $tr.css('visibility', 'visible')
        var tURL = '<%=request.getContextPath()%>/home/Folder.action?listSessionLogEvents=&sessionLogId=' + id;
        new Ajax.Updater($('#detailTR' + id), tURL, { 
            method: 'get',
            evalScripts: 'hidden'
        });
    } else {
        $tr.css('visibility', 'collapse')
    }
}
于 2013-09-17T04:04:58.683 回答