javascript - 如何在 JavaScript 中获取 td id
问题描述
<table class="table" style="margin-bottom:0px!important">
<b>
<? if(!empty($channelBase['rep_ids']))
{
$s_id=$channelBase['id'];
$i=0;
$temp='';
$reps_channl=explode(",",$channelBase['rep_ids']);
foreach($reps_channl as $k)
{
$added_reps = $rep_names[$k];
if($i==0){
$temp.='<tr style="border-top:none;">';
}
$temp.="<td id='".$s_id."_".$k."' class='repclicked' style='border-top:none;'>$added_reps <a href='#' class='btn btn-xs btn-icon btn-circle ' onclick='delete_repid($k,$s_id);'><i class='fa fa-close'></i></a>
</td>";
$i++;
if($i==5)
{
$temp.='</tr>';
$i=0;
}
}
echo $temp;
}
?>
</b>
</table>
在这里,我有一个td
带有数字值的 id。在这里,我对如何td
在 javascript 中获取 id 感到困惑。谁能帮帮我吗。
解决方案
这是您如何进入Ids
内td
表的方法
for (let row of mytab1.rows)
{
for(let cell of row.cells)
{
console.log(cell.id)
}
}
<div id="myTabDiv">
<table name="mytab" id="mytab1">
<tr>
<td id="id_1">col1 Val1</td>
<td id="id_2">col2 Val2</td>
</tr>
<tr>
<td id="id_3">col1 Val3</td>
<td id="id_4">col2 Val4</td>
</tr>
</table>
</div>
推荐阅读
- java - 如何提取 XML 块?
- dialogflow-es - dialogflow,Google 智能助理登录(包括 Google Home)
- java - 可以在不使用 AsyncTask 的情况下从 URL 获取 Json 吗?
- windows - 如何使用 Terraform 从存储帐户复制到本地主机“windows”
- r - 在 astsa ARIMA 图中使图更大
- javascript - 如何在新元素中显示文本翻译
- vhdl - 如何编写一个 vhdl 程序在 zynq 板的 ddr 内存中写入数字数据
- c++ - 使用模运算将整数转换为数组的问题
- php - 使用 PHP 循环遍历 POST 数组
- php - 碳获得当天的名称