How to debug a specific javascript click event?

耗尽温柔 提交于 2019-12-03 16:32:07

问题


On yahoo weather page, there is link labeled as C that changes temperature unit from Fahrenheit to Celsius.

I am looking debug this action and understand what javascript gets executed behind the scenes which convert F into C. What is the way of debug such things?

Link: http://weather.yahoo.com/?w=2295401


回答1:


Using Google Chrome,

  1. Right Click on an item which is changing 'visually' when the action you want to debug takes place, and click 'Inspect Element'. In this case we can inspect the temperature value

  2. Right Click again on the element from the DOM view and select Break on -> Attributes modifications

  3. Now perform the action you want to debug (in this case click the °C item)

You will notice that the code will 'Pause' and you can debug code in the debugger

In this case however, the code is compressed/minified so it will be very tough to understand what is actually going on, but the same approach could be used for other similar situations

Update:

Watch this Chrome Dev Tools video for lots of useful debugging tips: http://www.youtube.com/watch?v=BaneWEqNcpE



来源:https://stackoverflow.com/questions/13334709/how-to-debug-a-specific-javascript-click-event

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!