<!DOCTYPE html><html><head>? <style>p { margin-left:10px; color:blue; width:200px;? ? cursor:pointer; }span { color:red; cursor:pointer; }div.abs { width:50px; height:50px; position:absolute;? ? ? ? ? left:220px; top:35px; background-color:green;? ? ? ? ? cursor:pointer; }? </style>? <script src="http://code.jquery.com/jquery-latest.js"></script></head><body>? <div id="result">Click an element.</div><p>? This is the best way to <span>find</span> an offset.</p>?<div class="abs"></div>?<script>$("*", document.body).click(function (e) {? var offset = $(this).offset();? e.stopPropagation();? $("#result").text(this.tagName + " coords ( " + offset.left + ", " +? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? offset.top + " )");});?</script>?</body></html>代碼里面function(e)里面的e是一個參數(shù)嗎?為什么去掉之后就運行不出結(jié)果,代碼里面e的具體作用是什么定義參數(shù)的時候什么時候需要定義function() 什么時候需要定義funciton(e)?求解答
1 回答

紫羅天
TA貢獻12條經(jīng)驗 獲得超4個贊
event?對象,包含一些屬性信息,具體的可以百度js事件。至于為什么去掉e不行,是因為你在里面用到了e.stopPropagation(),這個是阻止事件冒泡 (這個我也不怎么懂)
- 1 回答
- 0 關(guān)注
- 1278 瀏覽
添加回答
舉報
0/150
提交
取消