check
will be a jQuery wrapper around an <input type="checkbox" />
element. As such, it contains no other elements, so check.html()
returns ""
. Remember that .html()
returns the stuff inside the element, not the element itself.
All jQuery wrappers are list-like; in this case, the list has only one element (that input
), which is found at check[0]
.
check[0] + 'test'
means "add a string to this input
element". As-is, that makes no sense, so the string representation of input
is used instead ("[object HTMLInputElement]"
).
If you want the string "test" after the element, you'll need to add that element to the DOM, then append the string after it.
$('#somecontainer').append(check).append("test");