我通过ID名称匹配ASP.Net生成的元素,但我有一些元素可以呈现为文本框或标签,这取决于页面上下文。为了知道是通过val()还是通过html()获取内容,我需要确定匹配的是文本框还是标签。
$("[id$=" + endOfIdToMatch + "]").each(function () {
//determine whether $(this) is a textbox or label
//do stuff
});
我找到了一个不起作用的解决方案,它只返回"undefined":
$("[id$=" + endOfIdToMatch + "]").each(function () {
alert($(this).tagName);
});
我遗漏了什么?
https://stackoverflow.com/questions/341900
复制相似问题