可以将jQuery选择器应用于元素而不是整个文档吗?

编程入门 行业动态 更新时间:2024-10-28 02:34:07
本文介绍了可以将jQuery选择器应用于元素而不是整个文档吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 jQuery('td[class=bgoff]').each(function() { var td = jQuery(this); ... no apply selector to "this" only });

我使用html中的表格数据,并尝试解析每个TD的内容不能唯一标识)。

I'm working with tabular data in html and trying to parse the contents of each TD (they are not uniquely identifiable).

使用XPath,我可以将this的路径添加到其他选择中。

Using XPath, I can prepend the path of "this" to additional selecting.

如何使用jQuery实现这一点?

How can I achieve this with jQuery?

推荐答案

您可以选择在选择器表达式之后提供第二个参数,并成为jQuery用于限制查找范围的上下文。了解详情此处

With jQuery you have the option of supplying a second parameter after the selector expression and that becomes a context that jQuery uses to limit scope of the lookup. Learn more here

更多推荐

可以将jQuery选择器应用于元素而不是整个文档吗?

本文发布于:2023-11-28 14:50:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1642857.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用于   而不是   元素   文档   选择器

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!