Используйте текущий элемент, чтобы выбрать его шаблон:
$(document).ready(function() {
$('.box').each(function(){
tippy(this, {
arrow: true,
arrowType: 'round',
size: 'large',
duration: 500,
animation: 'scale',
placement: 'left',
interactive: true,
theme: 'google',
content: this.querySelector('.tooltip_templates')
});
});
});
this.querySelector('.tooltip_templates')
выберет ребенка с этим классом, который будет использоваться в качестве контента.
Вы также можете избежать цикла .each()
, используя функцию для content
:
tippy('.box', {
animateFill: false,
arrow: true,
arrowType: 'round',
size: 'large',
duration: 500,
animation: 'scale',
placement: 'left',
interactive: true,
theme: 'google',
content: function (reference) {
return reference.querySelector('.tooltip_templates');
}
});