Skip to content
Advertisement

jQuery $(event.target) returns DOM in console, not HTML

With this code:

$(document).on('click', '.docs-tag', function(event){
    console.log($(event.target))
})

I expect to see:

[<some html>]

but instead get:

[span.icon-tag docs-tag child_hover dropdown-open, context: span.icon-tag docs-tag child_hover dropdown-open, constructor: function, init: function, selector: “”, jquery: “1.8.2”…]

I have recently upgraded to jQuery 1.8.2. Has there been a change in how $(event.target) is handled?

Advertisement

Answer

This has to do with changes in the browser output, it doesn’t have to do with jQuery. Here’s a thread on the subject – console.logging.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement