任何其他替代可见性崩溃的解决方案

时间:2013-09-17 03:55:19

标签: javascript jquery html css internet-explorer

大家好,我有IE10和chrome的问题。在扩展表后,IE10不会崩溃,对于chrome,它会在它之间留下空白..在ie8,firefox中工作。我已经尝试display:none并显示: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');
        }
    }

这是clickbutton函数

href =“#”onclick =“javascript:loadSessionLogEvents('$ {file.session.id}')”&gt;

1 个答案:

答案 0 :(得分:0)

根据评论,这里存在多个问题

  1. 您需要使用id-selector代替element selector eventTRdetailTR元素
  2. jQuery包装器对象没有名为style的属性,您需要使用.css()来获取和设置css值
  3. 尝试

    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')
        }
    }