gpt4 book ai didi

javascript - 通过创建 HTML 表来调用 javascript 函数

转载 作者:行者123 更新时间:2023-12-03 09:42:01 26 4
gpt4 key购买 nike

我想通过创建 html 表来调用函数。我要调用的函数称为 setHooks。更准确地说,这次如果添加了我的表格部件,我想调用函数(setHooks),以便该函数可以检查复选框是否需要钩子(Hook)HTML

'<td><form action=""><div class="myClass"><label><input type="checkbox" name="box'+index+'" '+setHooks('daten.identification','MyBox'+pageForBoxes+''+index) id="MyBox'+pageForBoxes+''+index+'" value="'+daten.identification+'" > Anzeigen</label></div></form></td></tr>');

这就是我尝试过的方法,但行不通,你能帮我吗?

JS

` function setHooks(id,myBox){

if(boxArr.indexof(id) != -1){
$(myBox).attr('checked', true)
}


}`

最佳答案

请参阅 td 末尾的 script 标记:

<td>
<form action="">
<div class="myClass">
<label>
<input type="checkbox" id="MyBox'+pageForBoxes+ ''+index+ '" value="'+daten.identification+ '"> Anzeigen
</label>
</div>
</form>
<script>
setHooks('daten.identification','MyBox' + pageForBoxes + '' + index); // Call it here
</script>
</td>

关于javascript - 通过创建 HTML 表来调用 javascript 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31159914/

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