javascript – jquery – 如何检查父元素是tbody还是thead?

前端之家收集整理的这篇文章主要介绍了javascript – jquery – 如何检查父元素是tbody还是thead?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我需要检查父项是tbody还是thead标记.

我现在有这个,这不起作用:

item.parent("thead")[0] = "<thead>" ? console.log("yes") : console.log("no");

虽然不起作用.

什么提示我做错了什么?

谢谢!

解决方法

认为这将有效:

console.log(item.parent("thead").is("thead") ? "Yes" : "No");

http://jsfiddle.net/G9LJT/0/ – 没有

http://jsfiddle.net/G9LJT/1/ – 是的

item.parent(“thead”)[0]指的是选择器的第一个DOM元素.

猜你在找的jQuery相关文章