Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 将每个块的日期值作为类添加_Jquery_Each - Fatal编程技术网

Jquery 将每个块的日期值作为类添加

Jquery 将每个块的日期值作为类添加,jquery,each,Jquery,Each,您好,我想获取每个日期值作为字符串,并将其作为类添加到文章$('.alle feesten'),它现在所做的是将所有值添加到每个块,以便每个块获得3个额外的类。每个块只应获取其日期,以便块1获取值1。。。提前谢谢 $('.alle-feesten').each(function(i) { $(this).addClass(zonderSlash($('.feest-datum').text())); }); function zonderSlash(datum) {

您好,我想获取每个日期值作为字符串,并将其作为类添加到文章$('.alle feesten'),它现在所做的是将所有值添加到每个块,以便每个块获得3个额外的类。每个块只应获取其日期,以便块1获取值1。。。提前谢谢

  $('.alle-feesten').each(function(i) {
    $(this).addClass(zonderSlash($('.feest-datum').text()));
  });

  function zonderSlash(datum) {
    datum_string = datum.split('/');
    new_date = datum_string[0] + datum_string[1] + datum_string[2]
    return new_date;
  }

假设
.feestdatum
.alleefeesten
的祖先,您可能希望这样做

$('.alle-feesten').each(function(i) {
    var self = $(this);
    self.addClass(zonderSlash(self.find('.feest-datum').text()));
});

你是说像这样的事吗

 var aux = 0;
 $('.alle-feesten').each(function(i) {
    $(this).addClass(zonderSlash($('.feest-datum').text()), aux); 
    aux++;
  });

  function zonderSlash(datum, i) {
    datum_string = datum.split('/');
    new_date = datum_string[i];
    return new_date;
  }

谢谢你的评论:)