jQuery('td[class=bgoff]').each(function() {
var td = jQuery(this);
... no apply selector to "this" only
});
I'm working with tabular data in html and trying to parse the contents of each TD (they are not uniquely identifiable).
Using XPath, I can prepend the path of "this" to additional selecting.
How can I achieve this with jQuery?
The :not() selector selects all elements except the specified element. This is mostly used together with another selector to select everything except the specified element in a group (like in the example above).
jQuery selectors allow you to select and manipulate HTML element(s). jQuery selectors are used to "find" (or select) HTML elements based on their name, id, classes, types, attributes, values of attributes and much more. It's based on the existing CSS Selectors, and in addition, it has some own custom selectors.
Q 1 - Which of the following is correct about jQuery selector? A - A jQuery Selector is a function which makes use of expressions to find out matching elements from a DOM based on the given criteria.
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
You can also use .find(expression) if you already have a jquery object within which you wish to search.
In your example:
jQuery('td[class=bgoff]').each(function() {
var td = jQuery(this);
$(td).find( <selector to search within td> );
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With