84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
This is a problem that I can’t solve even if I tear my brain apart↓
Front-ends! As shown in the figure, how to obtain the coordinate distance from the leftmost side of p to the mouse position?
光阴似箭催人老,日月如移越少年。
body{ margin:0; padding:0; } #p{ width:200px; height:100px; border:1px solid #000; position:absolute; } //如果p有定位父级元素存在还需要减去offsetTop值 $("#p").bind("click",function(ev){ console.log(ev.clientX - $(this).offset().left); })
$("p").on("click",function(e){ var disX = e.clientX - e.offsetX; //disX就是当前p最左侧到鼠标位置的坐标距离 });
光阴似箭催人老,日月如移越少年。