Javascript 从<;上的数据库获取详细信息值;tr>;悬停

Javascript 从<;上的数据库获取详细信息值;tr>;悬停,javascript,php,jquery,Javascript,Php,Jquery,大家好,我有个问题,我一时想不出来。我有一个从数据库返回值的循环,我希望每个值在JavaScript的onmouseover属性上查看它们的值。但它只显示所有标记的第一行值。下面是代码的php部分 $result = "<table id='displayDiv' width='1000' class='table_info table-bordered table-striped table-hover'> <tr>

大家好,我有个问题,我一时想不出来。我有一个从数据库返回值的循环,我希望每个值在JavaScript的onmouseover属性上查看它们的值。但它只显示所有标记的第一行值。下面是代码的php部分

$result = "<table id='displayDiv' width='1000' class='table_info table-bordered table-striped table-hover'>
                        <tr>
                            <td colspan='6' class='plate'>Follow-Up Events</td>
                        </tr>
                        <tr style='text-align:center; color:#FFF; background: #31B0D5;'>
                            <td>Customer</td>
                            <td>Plate</td>
                            <td class='col-md-4'>Problem</td>
                            <td>Date Created</td>
                            <td></td>
                        </tr>";

foreach ($followArray as $customer) {

$result = $result .
        "<tr style='text-align:center; background: #FFF; color:#105a99; font-weight:bold;'>
                    <td>$customer->company</td>
                    <td id='plate' onmouseover='plate();' onmouseout='plateout();'>$customer->plate</td>
                    <td>$customer->problem</td>
                    <td>$customer->date</td>
                </tr>";
}
$result = $result . "</table><div id'white'></div>";

谢谢您的帮助。

当您使用原生js时,只需将
传递到plate函数中,然后使用
此.innerHTML

还修复了html-id应该是唯一的,所以要么将其更改为类,要么在末尾附加一个唯一的数字(在下面的示例中,我已将其更改为类)-循环中不应该有id(除非您附加索引或类似的内容)

白色div中应该有一个
=

功能板(柱形单元){
document.getElementById('white').innerHTML=columnCell.innerHTML;
}
函数plateout(){
document.getElementById('white')。innerHTML='';
}

后续活动
顾客
盘子
问题
创建日期
$customer->company
$customer->plate
$customer->problem
$customer->date
$customer->company
$customer->plate1
$customer->problem
$customer->date
$customer->company
$customer->plate2
$customer->problem
$customer->date

您的所有元素都有id
标牌
。这需要是唯一的。请尝试使用
this.document.getElementById(“白色”).innerHTML
如何修复ID。如果我必须为每个div使用动态id,那么我必须在document.getElementById上使用每个id,这将非常乏味。非常感谢兄弟。你救了我一天。没问题,很高兴我能帮上忙:)
function plate() {
document.getElementById("white").innerHTML = $("#plate").text();
}
function plateout() {
 document.getElementById("white").innerHTML = "";
}