1 year ago

Get the value of select box with same class

Posted 1 year ago by pordonez


@foreach($test as $t)

<button id="btn">Choose</button>

<select name="select_test">
<option value="0">0</option>
<option value="1">1</option>


$('#btn').on('click', function() {
    var select = $('select[name="select_test"]').val();

Issue: I have 5 buttons and 5 select drop down. but when i click the 2nd, 3rd, 4th and 5th button it will display the 1st select value. its always the 1st select value.

How can i get the value of the select base on the button i clicked?.

Please sign in or create an account to participate in this conversation.