I'm matching ASP.Net generated elements by ID name, but I have some elements which may render as text boxes or labels depending on the page context. I need to figure out whether the match is to a textbox or label in order to know whether to get the contents by val() or by html().
$("[id$=" + endOfIdToMatch + "]").each(function () {
//determine whether $(this) is a textbox or label
//do stuff
});
I found a solution that doesn't work, it just returns "undefined":
$("[id$=" + endOfIdToMatch + "]").each(function () {
alert($(this).tagName);
});
What am I missing?
$(this).get(0).tagName
– Stoneware