Hi, I'm trying to create a form with multiple input fields. These fields should have a button to be able to check its content with .ajax. I am able to create this function for a single field, but i don't know what the best way would be to do it for multiple input fields:
input#item0 input#item1 input#item2 input#item3 ..... What would be the best way to create this with jquery so i can adjust a single var to create if for x items? Thx, Carlo $(document).ready(function(){ $("span#check0").click(function(event){ $("input#item0").ajaxStart(function(){ $(this).addClass("loading"); }); $("input#item0").ajaxStop(function(){ $(this).removeClass("loading"); }); $.ajax({ type: "GET", url: "checkitem.php", data: { 'sn': $('input#item0').val()}, 'success': function(msg) { if (msg == 'OK') {$("input#item0").removeClass("nowarranty").addClass("warranty");} if (msg == 'NG') {$("input#item0").removeClass("warranty").addClass("nowarranty");} }, 'error': function() {alert('Error: please try again');} }); }); });