當(dāng)鼠標(biāo)事件被觸發(fā)時(shí),clientX鼠標(biāo)事件屬性用于獲取鼠標(biāo)指針的水平坐標(biāo)。這是根據(jù)當(dāng)前窗口。
示例
您可以嘗試運(yùn)行以下代碼來(lái)了解如何實(shí)現(xiàn)clientX? JavaScript 中的鼠標(biāo)事件。
<!DOCTYPE html>
<html>
<body>
<p onclick = "coordsFunc(event)">
Click here to get the x (horizontal) and y (vertical) coordinates
(according to current window) of the mouse pointer.
</p>
<script>
function coordsFunc(event) {
var x_coord = event.clientX;
var y_coord = event.clientY;
var xycoords = "X coords= " + x_coord + ", Y coords= " + y_coord;
document.write(xycoords);
}
</script>
</body>
</html>
登錄后復(fù)制
以上就是在JavaScript中,clientX鼠標(biāo)事件的作用是什么?的詳細(xì)內(nèi)容,更多請(qǐng)關(guān)注www.92cms.cn其它相關(guān)文章!






