diff --git a/js/app/date_poll.js b/js/app/date_poll.js
index 8542c82c931d21ac27ee2ab1f52bdea4ba888eaa..222da491c43c71270b16c71f03012e20f048d293 100644
--- a/js/app/date_poll.js
+++ b/js/app/date_poll.js
@@ -93,7 +93,7 @@ $(document).ready(function () {
     function getLastDayNumber(last_day) {
         if (last_day == null)
             last_day = $selected_days.find('fieldset').filter(':last')
-        return parseInt(/^d([0-9]+)-h[0-9]+$/.exec(last_day.find('.hours').filter(':first').attr('id'))[1])
+        return parseInt(/^d([0-9]+)-h[0-9]+$/.exec($(last_day).find('.hours').filter(':first').attr('id'))[1])
     }
 
     function newDateFields(dateStr) {