在我的下面的代码中,在div标签的开头和表格标签之间没有br标签,但是在源代码中出现了几个br元素。
这是我在.php文件中的代码。
<div id='tx_addAccountpopup_frame' style = "height: 100px" class='txPopupFrame'>
<table class="addNewTable" id = "table" >
<tr><td align="left" class="spaceUnder"><label for='clearingAccount'>Clearing Acct</label></td><td align = "right" class="spaceUnder"><input type = "text" id = "clearingAccount" class="txAddNewField"></td></tr><br>
<tr><td align="left" class="spaceUnder"><label for='tposAlloc'>Tpos Alloc</label></td><td align = "right" class="spaceUnder"><input type = "text" id = "tposAlloc" style="text-transform: uppercase" class="txAddNewField"></td></tr><br>
<tr><td align="left" class="spaceUnder"><label for='tposPortfolio'>Tpos Portfolio</label></td><td align = "right" class="spaceUnder"><input type = "text" id = "tposPortfolio" style="text-transform: uppercase" class="txAddNewField"></td></tr><br>
<tr><td align="left" class="spaceUnder"><label for='tposGroup'>Tpos Group</label></td><td align = "right" class="spaceUnder"><input type = "text" id = "tposGroup" style="text-transform: uppercase" class="txAddNewField"></td></tr><br>
<tr><td align="left" class="spaceUnder"><label for='serverCode'>Server Code</label></td><td align = "right" class="spaceUnder"><input type = "text" id = "serverCode" class="txAddNewField"></td></tr><br>
<tr><td align="left" class="spaceUnder"><label for='clearingFirm'>Clearing Firm</label></td><td align = "right" class="spaceUnder"><select id = "clearingFirm" style="text-transform: uppercase" class="txAddNewField"></td></tr><br>
<tr><td align="left" class="spaceUnder"><label for='vtk'>VTK</label></td><td align = "right" class="spaceUnder"><input type = "text" id = "vtk" class="txAddNewField"></td></tr><br>
<tr><td align="left" class="spaceUnder"><label for='clearingAllocAccount'>Clearing Alloc</label></td><td align = "right" class="spaceUnder"><input type = "text" id = "clearingAllocAccount" style="text-transform: uppercase" class="txAddNewField"></td></tr><br>
<tr><td align="left" class="spaceUnder"><label for='portfolioDesc'>Portfolio Desc</label></td><td align = "right" class="spaceUnder"><input type = "text" id = "portfolioDesc" class="txAddNewField"></td></tr><br>
<tr><td align="left" class="spaceUnder"><label for='groupDescription'>Group Desc</label></td><td align = "right" class="spaceUnder"><input type = "text" id = "groupDescription" class="txAddNewField"></td></tr><br>
<tr><td align="left" class="spaceUnder"><label for='masterDescription'>Master Desc</label></td><td align = "right" class="spaceUnder"><input type = "text" id = "masterDescription" class="txAddNewField"></td></tr><br>
</table>
<button id = "submitNewAccount" onclick ="txSubmitNewAccount()"class = "txDefender_PermissionAddRecordButton" type = "button" width ="100" height="30">Submit</button>
</div>
以下是Google Chrom开发工具中显示的来源,您可以在其中看到添加的br标记:
<div id="tx_addUserpopup_frame" class="txPopupFrame">
<br><br><br><br><br><br><table class="addNewTable" id="table" cellspacing="10">
</table>
<button id="submitNewUser" onclick="txSubmitNewUser()" class="txDefender_PermissionAddRecordButton" type="button" width="100" height="30">Submit</button>
</div>
导致这种情况发生的原因是什么?我该如何解决或阻止它?
答案 0 :(得分:4)
在你的php中,<br>
的每一行都有一个<table>
,这在语法和语义上都是错误的。 Chrome会尝试将其修复为有效代码并将<br>
移至顶部。删除所有这些错误的<br>
,它就可以了。
...
<tr><td align="left" class="spaceUnder">[...]</td></tr><br>
^-- cannot go here, remove this
...