Why can't you call outerHTML on $(this)?

outerHTML is a DOM property; jQuery doesn't expose all DOM properties.

If you have a jQuery object, you can only directly access those properties and methods that jQuery exposes, and vice versa for DOM objects.

In object-oriented terms, jQuery objects don't inherit from DOM objects, they contain them.

Saying $x[0] gets you the DOM object for the first element represented by a jQuery object.


You can use directly this to access outerHTML of the current object instead of indirectly going through $(this) as this represents the DOM object (which has outerHTML property) whereas $(this) represents jQuery object.

this.outerHTML

jQuery selector returns an array-like jQuery object which has no outerHTML property.

However, the jQuery resulting array contains DOM elements.
It means that you can actually access it this way.

$(".someClass")[0].outerHTML // it works for me

Update: It works for me in every browser.
I can access array-like jQuery object in a click event handler as well.

$(".someClass").click(function()
{
    alert($(this)[0].outerHTML); // it works me too
});

Here is my JSFiddle: http://jsfiddle.net/13btf60p/

Update 2:

OK, now I get your question. It should have worked. Do you really need an IntelliSense to complete such a plain and simple construction?