Alert jQuery Objects

Sometimes we need to know a little more about jQuery objects returned by selectors, callback functions, etc.
It's so simple, we just need to execute an alert on object:

alert($('#objectId'));
Return: [object Object].
wrong answer...

You've probably seen this before.

The correct way:  alert($('#objectId').toSource());
So simple as before.

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.