javascript - How can i get the text box value on click button? -


i have 8 set of forms given below.all class names same , form names same. input providing different on forms. need input value text box when click on filter button.how can in jquery using $(this).? here have tried.

$(".filterit").click(function(){   $(this).$('myform').$('filter1').val(); }); 

html

    <form name="myform" method="post">         <table class="pop-table">         <tr><td><input type="text" value="" name="filter1" class="filter-1"><td></tr>         <tr><td><input type="text" value="" name="filter2" class="filter-2"></td></tr>         <tr><td><button class="btn btn-warning filterit">filter</button></td></tr></table>     </form> 

use .closest() traversed closest element , .find() search element class or id or selector , .val() getting input value

$(".filterit").click(function(){    $(this).closest('table').find('.filter-1').val(); // first text box    $(this).closest('table').find('.filter-2').val(); // second }); 

fiddle


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -