0

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) us handled?

Django Doctor
  • 8,450
  • 9
  • 45
  • 66
  • 1
    It's just how the DOM element (or jQuery object) is displayed in the console. No need to worry about it. – Felix Kling Jun 03 '13 at 22:16
  • if the element has an attribute 'data-thing'='some value', then doing $(event.target).data('thing') returns undefined. – Django Doctor Jun 03 '13 at 22:17
  • Works fine for me: http://jsfiddle.net/FxQJk/. But I use 1.8.3 in the fiddle, if it makes a difference. – Felix Kling Jun 03 '13 at 22:20
  • possible duplicate of [console.log() not outputting HTML of jQuery selection object](http://stackoverflow.com/questions/13268015/console-log-not-outputting-html-of-jquery-selection-object) – Felix Kling Jun 03 '13 at 22:21

3 Answers3

3

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.

Community
  • 1
  • 1
rogMaHall
  • 671
  • 4
  • 9
1

If you want to see the DOM node, do this:

console.log($(event.target)[0]);
Adam
  • 46,658
  • 11
  • 63
  • 84
0

event.target returns the DOM element, so you can retrieve any property/ attribute that has a value

try this

$(event.target).text()
PSR
  • 38,073
  • 36
  • 106
  • 149