简体   繁体   English

如何在Chrome中设置DOM断点

[英]how to set DOM Breakpoints in chrome

I'm trying to follow the tutorial here . 我正在尝试按照这里的教程进行操作。

I'm stuck on the section DOM Breakpoints (near the bottom). 我被困在DOM Breakpoints部分(在底部附近)。

I went to the example site they are talking about. 我去了他们正在谈论的示例站点 I pressed ctrl + shift + i and navigated to "elements" tab. 我按Ctrl + Shift + I ,然后导航到“元素”标签。 In the elements tab I found the following html section: 在元素选项卡中,我找到了以下html部分:

<div id="profileCard" style="position: absolute; left: 403px; top: 135px; visibility: hidden; display: none; " class="goog-hovercard">
</div>

Now I'm stuck trying to find the context menu: 现在,我一直在试图找到上下文菜单:

Bring up a context menu on the #profileCard element and select the events you want to break on: subtree modifications, attributes modifications, and the node removal 在#profileCard元素上弹出一个上下文菜单,然后选择要中断的事件:子树修改,属性修改和节点删除

Here is a screenshot to show where I am: 这是显示我所在位置的屏幕截图:

ss

To set break points in Chrome bring up the inspector like you have shown above and click on the scripts option at the top. 要在Chrome中设置断点,请像上面显示的那样调出检查器,然后单击顶部的脚本选项。 This will allow you to look at the scripts being used on the page and to insert break points on that page. 这将允许您查看页面上正在使用的脚本,并在该页面上插入断点。 As well as step through them and other useful debugging options. 以及逐步解决它们以及其他有用的调试选项。

The above is for javascript, to break on dom elements right click on the element (inside of the inspector) that you want to break on and it will bring up the context menu that allows you to break on subtree modifications and stuff like that. 上面是针对javascript的,要中断dom元素,请右键单击要中断的元素(在检查器内部),它将弹出上下文菜单,允许您中断子树修改和类似的操作。

Just wanted to add that you can simply right-click on an element in the elements panel and go to: 只需添加一下即可,您只需在Elements面板中右键单击一个元素,然后转到:

Break On... and select Subtree modifications , Attributes modifications , or Node removal Break On...然后选择子Subtree modificationsAttributes modificationsNode removal

在此处输入图片说明

  1. open element panel on devTools. 在devTools上打开元素面板。
  2. inspect or find out the DOM element. 检查或找出DOM元素。
  3. right click on it and select break on... 右键单击它,然后选择“中断...”

Subtree Modifications A subtree modification breakpoint is triggered when a child element is added, removed, or moved. 子树的修改子树修改时子元素的添加,移除或移动断点被触发。

Attributes Modifications An attribute modification occurs when the attribute of an element (class, id, name) is changed dynamically. 属性修改当元素的属性(类,id,名称)动态更改时,即发生属性修改。

Node Removal A node removal modification is triggered when the node in question is removed from the DOM. 节点删除当将有关节点从DOM中删除时,将触发节点删除修改。

Provide a exercise link here, Enjoy :) DOM Breakpoints Exercise‎ 在此处提供练习链接,请享受:) DOM断点练习

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM