Search code examples
javascripthtmljqueryfirefoxweb-inspector

How to set a inspected browser element as this


When inspecting an element in firefox, I would like to try jquery on it.

something like this

$(this).find('.myclass').first().val()

or whatever operations requires $(this). By default a this refers to the window. Can I set this to a particular element in inspect mode with a trivial effort?


Solution

  • When an element is selected in the panel, typing in $0 into the console will refer to that element. So you just need to replace this with $0:

    $($0).find('.myclass').first().val()