0

Here is the code snippet: http://jsbin.com/ekupa3/2/edit

I need to return the table rows (tr) that don't have a tag of 'test2'. the output should be an array of table rows (tr).

I spent a couple hours trying every JQuery technique I knew and I will bow to the experts.

2 Answers 2

3
var newTag = 'test2';
var rows_without_newTag = $("table tr").not(":contains(" + newTag + ")");

Created an edit of the OP's JS Bin w/ some example usage for posterity's sake.

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

Comments

1
var newTag = 'test2',
    $tr = $('tr').filter(function() {
        return $(this).html().indexOf('>' + newTag + '</a>') == -1;
    });

$tr will be a jQuery element array containing all tr not containing the tag test2. I included parts of the HTML in the indexOf check in case there was another tag called "another-test2" or the like.

See example →

1 Comment

this works great. It's a little less eloquent than i'd like but I'm not sure there is any other way.

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.