こんにちは、div から JavaScript 関数を呼び出す方法を知っている人はいますか? 私のdivと関数は次のようになります:
@foreach(var c in Model.matrix.Cells)
{
<tr>
<td class="tdHouse" >
<div onload="styleCell(event)" class="cell" id="styleCell" ondrop="drop(event,@c.row,@c.column)" ondragover="allowDrop(event)" alt="one">
</div>
<label hidden id="@c.room.Id" class="existRoomStyle" ondragstart="drag(event)" onmouseup="dragMouseUp(event)" title="@c.room.roomName" style= "background-color:@c.room.color"> @c.room.roomName</label>
<img hidden id="@c.socket.Id" alt="existSocket" class="existSocketStyle" src="~/Images/socket.jpg" draggable="true" ondragstart="drag(event)" onmouseup="dragMouseUp(event)" title="socket" alt="one"/>
<img hidden id="@c.socket.machine.Id"class="existMachineStyle" src="~/Images/MachineImages/@c.socket.machine.Image" draggable="true" ondragstart="drag(event)" title="machine" alt="one"/>
</td>
</tr>
}
<script>
function styleCell(ev) {
ev.target.children[0].appendChild(document.getElementById("existRoomStyle"));
ev.target.children[0].appendChild(document.getElementById("existSocketStyle"));
ev.target.children[0].appendChild(document.getElementById("existMachineStyle"));
}
</script>