title: Match dom element text(day) to xml day and append if the same?
body: <p>OK here's the problem, I have a calandar app that has date values displayed like so: </p>
  
  <pre><code>&lt;div class="date-cell ng-binding" date-cell="" cell-data-index="getDateCellDataIndex(column, row)" ng-repeat="column in columns"&gt; &lt;div ng-click="onDateCellClick()" custom-date-cell="" ng-class="{today: cellData.isToday, 'current-month': cellData.isCurrentMonth}" class="ng-scope ng-binding current-month"&gt; 1 &lt;/div&gt; &lt;/div&gt;
  </code></pre>
  
  <p>I also have a XML document loading on pagevia ajax, returning a date value and a price for that date, I am trying to correlate the date that is displayed in the dom element to the returned data from the xml and if it is the same day append the price value to that date. </p>
  
  <p>OK so heres the function i have which is failing miserably, it runs through all the dom elements every time returning and logging to the console all of the dates from the dom elements with every iteration instead of running it and correlating: </p>
  
  <pre><code>            function getRate(source, scope, dateSheet, dateSheetCtrl) {
                  var dateValue = $("Date", source).text() || "";
                  var thismonth = dateValue.substring(0,2);
                  if (!dateValue) {
                      return null;
                  }
                  var d = new Date();
                  var formattedmonthday = (getcalandardates &lt; 10) ? '0' + getcalandardates : getcalandardates;
                  var getcalandardates = $(".date-cell &gt; div").text();
                  var comparedates = getcalandardates.match(thisday);
                  var thisday = dateValue.substring(3,5);
                  var curr_date = d.getDate();
                  var curr_month = d.getMonth() +1;
                  var curr_mont = "0" + curr_month;
                  var curr_year = d.getFullYear();
                  var date_string = "0" + curr_month + "/0" + curr_date + "/" + curr_year;
                  var dailyPrice = $("DailyPrice", source).text() || "";
                  var weeklyPrice = $("WeeklyPrice", source).text() || "";
                  var monthlyPrice = $("MonthlyPrice", source).text() || "";
                  var isAvailable = $("IsAvailable", source).text() === "1";
                  var minimumStay = Number($("MinimumStay", source).text());
                  console.log(dailyPrice, weeklyPrice, monthlyPrice, isAvailable, minimumStay, dateValue , thismonth, getcalandardates);
                   if(curr_mont ==  thismonth  &amp;&amp; comparedates == thisday) {
                      $(this, 'div').append('&lt;p&gt;' + dailyPrice + '&lt;/p&gt;');
                      }
  
                  if (curr_mont ==  thismonth  &amp;&amp; getcalandardates == thisday){
                      $('.date-cell &gt; div').append('&lt;p&gt;' + dailyPrice + '&lt;/p&gt;');
                  }
                  /*if (date_string == dateValue) {
                      $('.date-cell &gt; .today ').append('&lt;p&gt;' + dailyPrice + '&lt;/p&gt;');
                  }*/
                  if (isNaN(minimumStay)) {
                      minimumStay = DEFAULT_MINIMUM_STAY;
                  }
  
                  return {
                      date: new Date(dateValue),
                      dailyPrice: dailyPrice,
                      weeklyPrice: weeklyPrice,
                      monthlyPrice: monthlyPrice,
                      reserved: !isAvailable,
                      minimumStay: minimumStay
                  };
  
              }
  </code></pre>
  
  <p>now this is the exact if statement i am using: </p>
  
  <pre><code>             if(curr_mont ==  thismonth  &amp;&amp; comparedates == thisday) {
                  $(this, 'div').append('&lt;p&gt;' + dailyPrice + '&lt;/p&gt;');
                  }
  </code></pre>
  
  <p>I can't wrap my head around it any help is much appreciated, I have a feeling i should be using a for statement not an if statement but i can't seem to get those to work either i have tried the following: </p>
  
  <pre><code>                    $('.date-cell').each(function() {
                   $(this).find(".date-cell &gt; div").text();
                   if(curr_mont ==  thismonth  &amp;&amp; getcalandardates == thisday) {
                      $(this, 'div').append('&lt;p&gt;' + dailyPrice + '&lt;/p&gt;');
                      }
                  });
  </code></pre>
  
  <p>and this: </p>
  
  <pre><code>                    $('.date-cell &gt; div ').text().each(function() {
                   if(curr_mont ==  thismonth  &amp;&amp; getcalandardates == thisday) {
                      $(this).append('&lt;p&gt;' + dailyPrice + '&lt;/p&gt;');
                      }
                  });
  </code></pre>
  
  <p>and a few other thing this is the 4th hr into this one little statement...</p>
  
  <p>the xml loggs the following to the console each time: </p>
  
  <pre><code>90 495  true 2 10/01/2014 10  28  29  30  31  1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  
  </code></pre>
  
  <p>Chris</p>
  
  <p>/<strong><em>*</em>****</strong><em>UPDATE</em><strong><em>*</em>**<em>*</em>**<em>*</em></strong>/</p>
  
  <p>OK i am getting closer this is my new function which is close it retrives the text values serpeatly but it still fails to append the dailyPrice and it doesn't stop running probably due to the fact it's being run inside of angularJS: </p>
  
  <pre><code>                $(".date-cell &gt; div").each(function () {
                      var gettextfunc = $(this).text();
                      if(curr_mont ==  thismonth  &amp;&amp; gettextfunc == thisday) {
                      $(".date-cell &gt; div").append('&lt;p&gt;' + dailyPrice + '&lt;/p&gt;');
                      return false;
                      }
                      console.log(gettextfunc);
                  });
  </code></pre>