reiniger Posted October 13, 2011 Report Share Posted October 13, 2011 Sveiki Nepieciešams padoms. ievadot clases w3 datus w1 + w3 attēlotos rez <table id="_table"> <tr> <td><input class="w1" /></td> <td><input class="w3" /></td> <td><input class="rez" /></td> </tr> <tr> <td><input class="w1" /></td> <td><input class="w3" /></td> <td><input class="rez" /></td> </tr> </table> $('#_table').delegate('.w3','keyup',function(){ var w_3 = $(this).val(); var w_1 = $(this).find(".w1").val(); alert('test: ' + w_3 + ' # ' + w_1); }); Kā var iegūt clases w1 val()? Lai varētu saskaitīt un attēlot class rez vietā! Link to comment Share on other sites More sharing options...
0 briedis Posted October 13, 2011 Report Share Posted October 13, 2011 (edited) $(this).closest("tr").find(".w1"); edit, jā, samudrījos :) Edited October 13, 2011 by briedis Link to comment Share on other sites More sharing options...
0 codez Posted October 13, 2011 Report Share Posted October 13, 2011 (edited) ideja tād, ka selektējam .w1 klasi, par kontekstu norādot .w3 parenta parentu, kurš ir tr tags. $('.w1',$(this).parent().parent()).val(); vai, ja find ir saprotamamāks, tad $(this).parent().parent().find('.w1').val() briedi, closest meklē tuvāko parentu. Edited October 13, 2011 by codez Link to comment Share on other sites More sharing options...
0 xPtv45z Posted October 13, 2011 Report Share Posted October 13, 2011 $(this).closest('tr').find('.w1') Link to comment Share on other sites More sharing options...
0 codez Posted October 13, 2011 Report Share Posted October 13, 2011 Plus tu vari šo eventu izmantot arī abām kolonnām: http://jsfiddle.net/nAMEL/1/ $('#_table').delegate('.w1,.w3','keyup',function(){ var $p=$(this).closest('tr'); var w1=$p.find('.w1').val(); var w3=$p.find('.w3').val(); $p.find(".rez").val(Number(w1)+Number(w3)) }); Link to comment Share on other sites More sharing options...
0 reiniger Posted October 13, 2011 Author Report Share Posted October 13, 2011 codez tu esi monstrs. Liels paldies. Link to comment Share on other sites More sharing options...
Question
reiniger
Sveiki
Nepieciešams padoms.
ievadot clases w3 datus w1 + w3 attēlotos rez
Kā var iegūt clases w1 val()? Lai varētu saskaitīt un attēlot class rez vietā!
Link to comment
Share on other sites
5 answers to this question
Recommended Posts