Chrome Developer Tools Tips
https://www.youtube.com/watch?v=2zmUSoVMyRU
- Use JQuery selector
- Use
document.querySelector
anddocument.querySelectorAll
to find elements by selector (without JQuery) document.querySelectorAll
is aliased by$$
- Use
- To not lose console session when refreshing page, right click console and select “Preserve log upon navigation”
document.body.contentEditable = true
allows us to change anything on the document.console.log('Window',window)
to log the object to the console.- To look at events for element, use
getEventListeners(element)
to find all the different event listeners. - call
monitorEvents(element)
to log all events of element to console- key events, mouse events, etc.
- use
monitorEvents(element, 'click')
to only get click events - the event can only be an array
unmonitorEvents(element)
to stop logging all events
- use
console.time('name_of_timer')
that can starts timersconsole.timeEnd('name_of_timer')
to stop timer
- use
console.groupCollapsed('Name')
to group console prints together- use
console.groupEnd()
to stop the group
- use
- use
console.table(myArray)
to create object table for array - use
$_
to access last result of console - use
clear()
to clear console;ctl-L
- get stack via
console.trace()
- use
console.count('name')
to count the number of times this gets hit - use
profile('function')
to start profiling andprofileEnd('function')
to stop profiling - use
dir(element)
to list all of the properties of the object - use
inspect(element)
to immediately go to the element in the elements area of the debugging tools - use
$0
to get last selected element,$1
for second to last, all the way up to$4