本文介绍了为什么IE-11使用style =" display:inline-block;"中断DOM? ?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下HTML表格



I have the following HTML table

<table width="100%" id="tbl1" cellpadding="4">
	<tr>
		 <td bgcolor="#F2F2F2" class="FieldNames">
			Table Data
		</td>     
	</tr>
	<tr style="display: inline-block;">
		 <td bgcolor="#F2F2F2" class="FieldNames">
			Table Data
		</td>     
	</tr>
	<tr id="tr1">
		<td bgcolor="#F2F2F2" class="FieldNames">
			Table Data
		</td>                                                        
	</tr>
</table>





如果我在JavaScript中访问此表行,则只显示2。





if I am accessing this table rows in JavaScript it only shows 2.

var tbl1= document.getElementById('tbl1');
alert(tbl1.rows.length);//return only 2





如果我删除'style =显示:inline-block;'从中间行开始,它工作正常并返回3.



IE-11中是否有与DOM处理相关的更改?





将以下HTML代码放在HTML文件中。运行并单击按钮。问题将是可见的





If i remove the 'style="display: inline-block;"' from middle row, it is working fine and returning 3.

Is there any DOM processing related changes in IE-11?


Just put following HTML code in a HTML file. Run and click on the button. Issue will be visible

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Manish Test</title>
   <script type="text/javascript" lang="javascript">
        function showcount()
        {
            var tbl1= document.getElementById('tbl1');
            alert(tbl1.rows.length);//return only 2
            return false;
        }
    </script>
</head>
<body>     
    <table width="100%" id="tbl1" cellpadding="4">
	<tr>
		 <td bgcolor="#F2F2F2" class="FieldNames">
			Table Data
		</td>     
	</tr>
	<tr style="display: inline-block;">
		 <td bgcolor="#F2F2F2" class="FieldNames">
			Table Data
		</td>     
	</tr>
	<tr id="tr1">
		<td bgcolor="#F2F2F2" class="FieldNames">
			Table Data
		</td>                                                        
	</tr>
</table>
    <input type="button" id="btnTest" value="Test" onClick="showcount();" />
</body>
</html>







我的IE-11确切版本是11.0 .9600.16428




My IE-11 exact version is 11.0.9600.16428

推荐答案

var rowCount = jQuery('#tbl1 tr').length;


这篇关于为什么IE-11使用style =&quot; display:inline-block;&quot;中断DOM? ?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 11:04