How to debug a specific javascript click event?

前端 未结 1 468
梦谈多话
梦谈多话 2021-02-07 10:59

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

相关标签:
1条回答
  • 2021-02-07 11:08

    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)

    Inspect Element

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

    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

    0 讨论(0)
提交回复
热议问题