Jump to content
php.lv forumi
  • 0
Sign in to follow this  
goma smile

Jquery parbaude

Question

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....

Share this post


Link to post
Share on other sites

6 answers to this question

Recommended Posts

  • 0

 

 

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 by anonīms

Share this post


Link to post
Share on other sites
  • 0

$('.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....

Share this post


Link to post
Share on other sites
  • 0

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

Share this post


Link to post
Share on other sites
  • 0

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... ?

Share this post


Link to post
Share on other sites
  • 0

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 by codez

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

×
×
  • Create New...