The document must have a small image of yourself which must

The document must have a small image of yourself, which must appear at the position of the mouse cursor when the mouse button is clicked, regardless of the position of the cursor at the time. I want it in javascript,

Solution

<!DOCTYPE html>

<html>

<head>

<style>

div {

width: 200px;

height: 100px;

border: 1px solid black;

}

</style>

</head>

<body onclick=\"placeImg(this)\">

<div id=\"demo\">

<img src=\"abc.jpg\">

</div>

<script>

function placeImg(event) {

var x = event.clientX;

var y = event.clientY;

var z=document.getElementById(\'demo\');

z.style.top=y;

z.style.left=x;

}

</script>

</body>

</html>

The document must have a small image of yourself, which must appear at the position of the mouse cursor when the mouse button is clicked, regardless of the posi

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site