Tag: 标记名

访问jquery对象的TagName

我想知道jquery对象的tagName,我试过: var obj = $(“”); alert($(obj).attr(“tagName”)); 此警报显示undefined 。 我做错了什么?

jQuery查找输入类型(但也适用于select)

我需要找到单选按钮,文本和选择的输入类型。 使用很容易找到任何输入类型,因为$(this).attr(“type”)将返回x 我的问题是我需要支持元素,它们没有type属性。 最终目标是返回收音机,文本或选择。 我想做这样的事情,但我很好奇,如果有更好的方法: if ($(this).tagName == “input”) { var result = $(this).attr(“type”); //returns radio or text (the attr type) } else { var result = $(this).tagName; //returns select (the element type) } 谢谢大家!

jQuery / javascript替换标签类型

是否有一种简单的方法可以遍历所有td标签并将其更改为th? (等等)。 我目前的方法是用th包装然后删除td,但后来我失去了其他属性等。