0

how to use jquery .each to loop through all input controls except those which have a specific class?

I have the current which loops through all and I want to exclude those with @class="static"

    $('input[type = "text"]').each(function () {
        var value = { QuestionId: $(this).attr('id'), Answer: $(this).val() };
        surveyResults.push(value)
    });

1 Answer 1

2

Try this

$('input[type = "text"]:not(.your-specefic-class)').each(function () {
    var value = { QuestionId: $(this).attr('id'), Answer: $(this).val() };
    surveyResults.push(value)
});
Sign up to request clarification or add additional context in comments.

4 Comments

Awe yes, by using not. Thanks!
If this worked for you. Make sure to mark it as the best answer so others may find it useful.
This did work for me but I don't see where to accept it as the answer.
@GoGetSOme This will help you How does accepting an answer work?

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.