-1

Is it possible to restrict where it looks for the certain text?

$(data,'table tr').each(function(){

});

Is what I have right now. Am I any where near right?

1
  • can you expand on what you are trying to do? you code is iterating through all rows in "data" where data is a DOM object Commented Oct 26, 2011 at 3:17

2 Answers 2

2

See jQuery() (aka the $() function) and see the supported forms.

It would likely be $(selector, context) where context is "A DOM Element, Document, or jQuery".

Alternatively, create a jQuery object and then apply the appropriate traversing function(s).

Happy coding.

Sign up to request clarification or add additional context in comments.

1 Comment

that's one of those things I know, but never think of using for some reason.
0

I believe this is what you're looking for: How to skip to next iteration in jQuery.each() util?

var arr = [ "one", "two", "three", "four", "five" ];
$.each(arr, function(i) {
    if(arr[i] == 'three') {
        return true;
    }
    alert(arr[i]);
});

You can check certain conditions on the tr, like, does it have children? And if so, skip to the next iteration.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.