gpt4 book ai didi

javascript - Object.innerHTML 未设置值

转载 作者:行者123 更新时间:2023-11-28 20:38:50 25 4
gpt4 key购买 nike

我正在使用 object.innertHTML 来设置 HTML 结构。但它没有设置初始TR和TD元素。下面是代码

 var previousInnerHTML = new String();
previousInnerHTML = previousInnerHTML.concat("<TR class='evenrow ' __eventAdded='true' isSubTotalRow='false' usable='false' index='40'><TD><INPUT id=check_table1 onclick=WebForm.markRowForSelection(event) type=checkbox xformstype='checkbox' doEBIValidate='false' __cID='c514' transactional='true' model='null' freemodel='false' databound='true' freeform='false' _initialized='true' originalTitle dataBoundElement='true' selectnotifier='true' trueValue='null' falseValue='null'></INPUT></TD><TD><DIV id=xfe2 class=fieldsbox><INPUT id=output2 class=input title='Provide value for Output2' type=text xformstype='input' doEBIValidate='false' __parent='table1' __cID='c515' transactional='true' model='null' freemodel='false' databound='true' freeform='false' _initialized='true' originalTitle='Provide value for Output2' xql='.//ID' ref='.//ID' _inTable='true' dataBoundElement='true'></DIV></TD><TD><DIV id=xfe4 class=fieldsbox><INPUT id=output4 class='input output' title='Value for Output4' readOnly xformstype='output' doEBIValidate='false' __parent='table1' __cID='c516' transactional='true' model='null' freemodel='false' databound='true' freeform='false' _initialized='true' originalTitle='Value for Output4' xql='EMPID' isOutputControl='true' ref='EMPID' _inTable='true' dataBoundElement='true'></DIV></TD><TD><DIV id=xfe6 class=fieldsbox><INPUT id=output5 class='input output' title='Value for Output5' readOnly xformstype='output' doEBIValidate='false' __parent='table1' __cID='c517' transactional='true' model='null' freemodel='false' databound='true' freeform='false' _initialized='true' originalTitle='Value for Output5' xql='ROLEID' isOutputControl='true' ref='ROLEID' _inTable='true' dataBoundElement='true'></DIV></TD><TD><DIV id=xfe8 class=fieldsbox><INPUT id=output3 class='input output' title='Value for Output3' readOnly xformstype='output' doEBIValidate='false' __parent='table1' __cID='c518' transactional='true' model='null' freemodel='false' databound='true' freeform='false' _initialized='true' originalTitle='Value for Output3' xql='num1' isOutputControl='true' ref='num1' _inTable='true' dataBoundElement='true'></DIV></TD><TD><DIV id=xfe10 class=fieldsbox><INPUT id=output1 class='input output' title='Value for Output1' readOnly xformstype='output' doEBIValidate='false' __parent='table1' __cID='c519' transactional='true' model='null' freemodel='false' databound='true' freeform='false' _initialized='true' originalTitle='Value for Output1' xql='num2' isOutputControl='true' ref='num2' _inTable='true' dataBoundElement='true'></DIV></TD></TR>");

var buttonObject = document.createElement("");
buttonObject.innerHTML = previousInnerHTML;

但是输出获取是

"<INPUT id=check_table1 onclick=WebForm.markRowForSelection(event) type=checkbox xformstype="checkbox" doEBIValidate="false" __cID="c514" transactional="true" model="null" freemodel="false" databound="true" freeform="false" _initialized="true" originalTitle dataBoundElement="true" selectnotifier="true" trueValue="null" falseValue="null"></INPUT></TD><TD>
<DIV id=xfe2 class=fieldsbox><INPUT id=output2 class=input title="Provide value for Output2" type=text xformstype="input" doEBIValidate="false" __parent="table1" __cID="c515" transactional="true" model="null" freemodel="false" databound="true" freeform="false" _initialized="true" originalTitle="Provide value for Output2" xql=".//ID" ref=".//ID" _inTable="true" dataBoundElement="true"></DIV></TD><TD>
<DIV id=xfe4 class=fieldsbox><INPUT id=output4 class="input output" title="Value for Output4" readOnly xformstype="output" doEBIValidate="false" __parent="table1" __cID="c516" transactional="true" model="null" freemodel="false" databound="true" freeform="false" _initialized="true" originalTitle="Value for Output4" xql="EMPID" isOutputControl="true" ref="EMPID" _inTable="true" dataBoundElement="true"></DIV></TD><TD>
<DIV id=xfe6 class=fieldsbox><INPUT id=output5 class="input output" title="Value for Output5" readOnly xformstype="output" doEBIValidate="false" __parent="table1" __cID="c517" transactional="true" model="null" freemodel="false" databound="true" freeform="false" _initialized="true" originalTitle="Value for Output5" xql="ROLEID" isOutputControl="true" ref="ROLEID" _inTable="true" dataBoundElement="true"></DIV></TD><TD>
<DIV id=xfe8 class=fieldsbox><INPUT id=output3 class="input output" title="Value for Output3" readOnly xformstype="output" doEBIValidate="false" __parent="table1" __cID="c518" transactional="true" model="null" freemodel="false" databound="true" freeform="false" _initialized="true" originalTitle="Value for Output3" xql="num1" isOutputControl="true" ref="num1" _inTable="true" dataBoundElement="true"></DIV></TD><TD>
<DIV id=xfe10 class=fieldsbox><INPUT id=output1 class="input output" title="Value for Output1" readOnly xformstype="output" doEBIValidate="false" __parent="table1" __cID="c519" transactional="true" model="null" freemodel="false" databound="true" freeform="false" _initialized="true" originalTitle="Value for Output1" xql="num2" isOutputControl="true" ref="num2" _inTable="true" dataBoundElement="true"></DIV></TD></TR>"

初始 TR 和 TD 元素丢失。可能是什么原因

最佳答案

如果您想像现在一样插入一大块 HTML,并且不想替换父对象(您的表格)的整个 .innerHTML,请使用 .insertAdjacentHTML().

演示: jsFiddle

脚本:

var containerObject = document.getElementById("table1"); 
containerObject.insertAdjacentHTML( 'beforeEnd', "<TR class='evenrow ' __eventAdded='true' isSubTotalRow='false' usable='false' index='40'><TD><INPUT id=check_table1 onclick=WebForm.markRowForSelection(event) type=checkbox xformstype='checkbox' doEBIValidate='false' __cID='c514' transactional='true' model='null' freemodel='false' databound='true' freeform='false' _initialized='true' originalTitle dataBoundElement='true' selectnotifier='true' trueValue='null' falseValue='null'></INPUT></TD><TD><DIV id=xfe2 class=fieldsbox><INPUT id=output2 class=input title='Provide value for Output2' type=text xformstype='input' doEBIValidate='false' __parent='table1' __cID='c515' transactional='true' model='null' freemodel='false' databound='true' freeform='false' _initialized='true' originalTitle='Provide value for Output2' xql='.//ID' ref='.//ID' _inTable='true' dataBoundElement='true'></DIV></TD><TD><DIV id=xfe4 class=fieldsbox><INPUT id=output4 class='input output' title='Value for Output4' readOnly xformstype='output' doEBIValidate='false' __parent='table1' __cID='c516' transactional='true' model='null' freemodel='false' databound='true' freeform='false' _initialized='true' originalTitle='Value for Output4' xql='EMPID' isOutputControl='true' ref='EMPID' _inTable='true' dataBoundElement='true'></DIV></TD><TD><DIV id=xfe6 class=fieldsbox><INPUT id=output5 class='input output' title='Value for Output5' readOnly xformstype='output' doEBIValidate='false' __parent='table1' __cID='c517' transactional='true' model='null' freemodel='false' databound='true' freeform='false' _initialized='true' originalTitle='Value for Output5' xql='ROLEID' isOutputControl='true' ref='ROLEID' _inTable='true' dataBoundElement='true'></DIV></TD><TD><DIV id=xfe8 class=fieldsbox><INPUT id=output3 class='input output' title='Value for Output3' readOnly xformstype='output' doEBIValidate='false' __parent='table1' __cID='c518' transactional='true' model='null' freemodel='false' databound='true' freeform='false' _initialized='true' originalTitle='Value for Output3' xql='num1' isOutputControl='true' ref='num1' _inTable='true' dataBoundElement='true'></DIV></TD><TD><DIV id=xfe10 class=fieldsbox><INPUT id=output1 class='input output' title='Value for Output1' readOnly xformstype='output' doEBIValidate='false' __parent='table1' __cID='c519' transactional='true' model='null' freemodel='false' databound='true' freeform='false' _initialized='true' originalTitle='Value for Output1' xql='num2' isOutputControl='true' ref='num2' _inTable='true' dataBoundElement='true'></DIV></TD></TR>")

HTML:

<table id="table1">
</table>

关于javascript - Object.innerHTML 未设置值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14785654/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com