1

Is there a way to set a var on change of 1 of many inputs in a div, something like:

$('#afwijkende_prijzen_vak'+nexty).find('input:text').val('');

If there changes a input in that div (text, select or radio) i wat to set a var to recognize a change.

1 Answer 1

3

I'm not sure what "set a var to recognize a change" means exactly, but here's what I'd do to change a variable when an input inside a particular element is changed:

var myVar;

$('#someDiv input, #someDiv select').each(function() {
    $(this).change(function() {
        // do stuff with things
        myVar = 42;
    });
});

Or:

$('#someDiv').find('input, select').each(function() { ... });
Sign up to request clarification or add additional context in comments.

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.