html - how to call javaScript function from div -
hello know how call javascript function div? div , function this:
@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>
you can't call onload way. w3schools list no-load applicable must separate function call div.
see answer how add onload event div element?
Comments
Post a Comment