简体   繁体   中英

how can i find if a certain part of the screen is clicked?

I can find if the screen is clicked, but where it is clicked. I have tried

.click(margin=10?){alert("you clicked at margin 10!")}

but it for some reason the syntax says the margin is unset

You can begin with something like below one.

the below code simply add a document wide click listener and retrieve the X and Y coordinates of the pointer click.

 document.addEventListener('click',function(e){ console.log(e.clientX, e.clientY); });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM