<div class=test> <input id='inTest'> <button type='button' id='add'>Отправить</button> </div>
<script> $('#add').on('click', function () { alert($('#inTest').parents('.test').val()); });</script>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <div class=test> <input id='inTest'> <button type='button' id='add'>Отправить</button> </div> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $('#add').on('click', function(){ alert($(this).siblings('#inTest').val()); }); </script> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <div class=test> <input id='inTest'> <button type='button' id='add'>Отправить</button> </div> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $('#add').on('click', function(){ alert($('#inTest').val()); }); </script> </body> </html>
<div class=test> <input id='inTest' > <input id='inTest' > <button type='button' id='add'>Отправить</button> </div>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <div class=test> <input id='inTest' name='val[]'> <input id='inTest' name='val[]'> <button type='button' id='add'>Отправить</button> </div> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $('#add').on('click', function(){ $(this).siblings('input').each(function(){ alert(this.value); }); }); </script> </body> </html>
$('#test').on('click', 'add', function(){ $(this).siblings('#inTest').each(function(){ $(this).attr('disabled', false); }); });