本文介绍了可以将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选择器应用于元素而不是整个文档吗?
发布评论