goma smile Posted August 2, 2013 Report Posted August 2, 2013 Ka parbaudit ar jquery ka ir piemeram x daudzumu <span class="total_id">x</span> <span class="real_id">x</span> <span class="total_id">32</span> <span class="real_id">2</span> <span class="total_id">32</span> <span class="real_id">32</span> <span class="total_id">32</span> <span class="real_id">4</span> <span class="total_id">12</span> <span class="real_id">4</span> <span class="total_id">32</span> <span class="real_id">12</span> Ka parbaudit ar jquery vai visos span pretejas vertibas total_id <->real_id ir vienadas vertibas....
0 anonīms Posted August 2, 2013 Report Posted August 2, 2013 (edited) Ka parbaudit ar jquery ka ir piemeram x daudzumu <span class="total_id">x</span> <span class="real_id">x</span> $('.total_id').length ? Ka parbaudit ar jquery vai visos span pretejas vertibas total_id <->real_id ir vienadas vertibas.... iemauc viņus parentā un izej ar to pašu .each kaut vai cauri Edited August 2, 2013 by anonīms
0 goma smile Posted August 2, 2013 Author Report Posted August 2, 2013 $('.total_id').length ? iemauc viņus parentā un izej ar to pašu .each kaut vai cauri ok if <span class="cikls" id="1"> <span class="total_id">11</span> <span class="real_id">11</span> </span> <span class="cikls" id="2"> <span class="total_id">22</span> <span class="real_id">12</span> </span> <span class="cikls" id="3"> <span class="total_id">33</span> <span class="real_id">13</span> </span> <span class="cikls" id="4"> <span class="total_id">42</span> <span class="real_id">42</span> </span> <span class="cikls" id="5"> <span class="total_id">53</span> <span class="real_id">33</span> </span> un $('.cikls').each(function() { var total_id = $(this).find('.total_id').text(); var real_id = $(this).find('.real_id').text(); }); bet ka nočekot vai visiem ir vienādas vērtības un ja ir tad kkas izlec....
0 gurkjis Posted August 2, 2013 Report Posted August 2, 2013 1. pirms each ieseto flagu var all_matches = true; 2. each blokā taisi ifu: ja kaut vienā gadījumā total_id nesakrīt ar real_id, tad liec all_matches = false; 3. pēc each bloka skaties, vai all_matches joprojām ir true, ja ir, tad izpildi savu "kkas izlec" daļu
0 goma smile Posted August 5, 2013 Author Report Posted August 5, 2013 1. pirms each ieseto flagu var all_matches = true; 2. each blokā taisi ifu: ja kaut vienā gadījumā total_id nesakrīt ar real_id, tad liec all_matches = false; 3. pēc each bloka skaties, vai all_matches joprojām ir true, ja ir, tad izpildi savu "kkas izlec" daļu es jau tā biju meiģinājis cipa: var all_matches = true; $('.cikls').each(function(i) { var total_id = $(this).find('.total_id').text(); var real_id = $(this).find('.real_id').text(); if(total_id != real_id){ var all_matches = false; } }); alert(all_matches); Bet viņs rāda visu laiku true par spīti tam ka dažas vietās nav vienāds., to var all_matches = false; nevar uztaisīt globālu... ?
0 codez Posted August 5, 2013 Report Posted August 5, 2013 (edited) Visa problēma ir tajā, ka ar: var all_matches = false; tu pārdefinē mainīgo. Noņem var, ja gribi izmantot to, ko definēji iepriekš. Edited August 5, 2013 by codez
Question
goma smile
Ka parbaudit ar jquery ka ir piemeram x daudzumu <span class="total_id">x</span> <span class="real_id">x</span>
<span class="total_id">32</span> <span class="real_id">2</span>
<span class="total_id">32</span> <span class="real_id">32</span>
<span class="total_id">32</span> <span class="real_id">4</span>
<span class="total_id">12</span> <span class="real_id">4</span>
<span class="total_id">32</span> <span class="real_id">12</span>
Ka parbaudit ar jquery vai visos span pretejas vertibas total_id <->real_id ir vienadas vertibas....
6 answers to this question
Recommended Posts