我需要调试一个使用jQuery的Web应用程序来做一些相当复杂和混乱的DOM操作.有一次,某些与特定元素绑定的事件不会被触发,只是停止工作.
如果我有能力编辑应用程序源代码,我会向下钻取并添加一堆Firebug console.log()语句并注释/取消注释代码片段以尝试查明问题.但我们假设我无法编辑应用程序代码,需要使用Firebug或类似工具完全在Firefox中工作.
Firebug非常善于让我导航和操纵DOM.但到目前为止,我还没有弄清楚如何使用Firebug进行事件调试.具体来说,我只想查看在给定时间绑定到特定元素的事件处理程序列表(使用Firebug JavaScript断点来跟踪更改).但是Firebug没有能力看到绑定事件,或者我太笨了而无法找到它.:-)
任何建议或想法?理想情况下,我只想查看和编辑绑定到元素的事件,类似于今天我可以编辑DOM的方式.
event.stopPropagation()和之间有什么区别event.stopImmediatePropagation()?
我有一个表结构,看起来像:
<table>
<tr id="row1">
<td>
<div>row 1 content1</div>
</td>
<td>
<div>row 1 content2</div>
</td>
<td>
<div>row 1 content3</div>
</td>
</tr>
<tr id="row2">
<td>
<div>row 2 content1</div>
</td>
<td>
<div>row 2 content2</div>
</td>
<td>
<div>row 2 content3</div>
</td>
</tr>
<tr id="row3">
<td>
<div>row 3 content1</div>
</td>
<td>
<div>row 3 content2</div>
</td>
<td>
<div>row 3 content3</div>
</td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
使用jQuery我试图在第三行的第二个单元格中选择DIV.我尝试了以下(除其他外):
var d = $('#row3').children(':eq(1)').children(':eq(0)');
Run Code Online (Sandbox Code Playgroud)
我得到的是一个带有单个元素的数组(我之后是DIV),然后我必须使用d [0]进行访问.为什么jQuery返回单个元素数组,我认为使用上面的选择器会直接返回DIV元素?
@ Shog9 - Duh ......好吧我的大脑刚启动,我现在就知道了.干杯.