I am sure there is a simple solution.
The starting scenario was the following.
I create a <select> element and populate it dynamycally:
function CreateDropDown(name, id, optionList)
{
var combo = $("<select></select>").attr("id", id).attr("name", name);
$.each(optionList, function (i, item) {
combo.append("<option value='"+item.val+"'>" + item.el + "</option>");
});
return combo;
}
The aim was to extract the outerHTML. The following works right:
combo[0].outerHTML();
But I feel that indexing the array is very rough. At least in all that cases where the jQuery() function return a single element array.
Question
Whenever the jQuery() function return a single element array, is it possible to get the unique element without array indexing?
If you “feel that indexing the array is very rough”, you could write your own nice helper method. Something like a:
Usage: