亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

關于function(e)的疑惑

關于function(e)的疑惑

ken0510 2016-08-13 15:37:13
<!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是一個參數嗎?為什么去掉之后就運行不出結果,代碼里面e的具體作用是什么定義參數的時候什么時候需要定義function() 什么時候需要定義funciton(e)?求解答
查看完整描述

1 回答

?
紫羅天

TA貢獻12條經驗 獲得超4個贊

event?對象,包含一些屬性信息,具體的可以百度js事件。至于為什么去掉e不行,是因為你在里面用到了e.stopPropagation(),這個是阻止事件冒泡 (這個我也不怎么懂)

查看完整回答
反對 回復 2016-08-13
  • 1 回答
  • 0 關注
  • 1299 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號