0

I don't know how to trigger an input if this is a array.

I can read the value, but i don't know what is the input that have made the event.

$('input[name^="months"]').change(function() {
alert($(this).val());
});

<input type="text" name="months[january]" value="100">
<input type="text" name="months[february]" value="150">

Thanks.

1 Answer 1

2

the change() function includes event

$('input[name^="months"]').change(function(event) {
    console.log(event.target);
    alert($(this).val());
});
Sign up to request clarification or add additional context in comments.

3 Comments

And do you know a easy method for get the month (january) instead of parse all the text, because my output is like this. <input alt="months[january]" type="checkbox" id="months[january]" name="months[january]" value="1" checked="">
do you mean get the value out of that textbox? is $(this).val() not working?
@stackoverfloweth i did an answer about this

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.