setInterval
: https://jsfiddle.net/j29pf67j/1/var counter = document.getElementById("counter")
var hiddenText = document.getElementById("hidden-text")
var run = function(seconds) {
var interval = setInterval(function(){
if (seconds > 0) {
counter.textContent = seconds--;
}
else
{
hiddenText.style.display = "block";
counter.style.display = "none";
clearInterval(interval);
}
}, 1000)
}
var items = [
{ name: 'Edward', value: 21 },
{ name: 'Sharpe', value: 37 },
{ name: 'And', value: 45 },
{ name: 'The', value: -12 },
{ name: 'Magnetic' },
{ name: 'Zeros', value: 37 }
];
items.sort(function (a, b) {
if (a.value > b.value) {
return 1;
}
if (a.value < b.value) {
return -1;
}
// a must be equal to b
return 0;
});
var index = jQuery('#side-nav a').index(this);
jQuery("#main-container-background").animate({ top: index * - 360 + '%' }, 'slow');
<span class="animated fadeIn">Test 6</span>
<div class="news">
some news1
<button class="like" data-id="1">like</button>
</div>
<div class="news">
some news2
<button class="like" data-id="2">like</button>
</div>
$(document).on('click','.like',function(){
id = $(this).attr('data-id');
// твоя функция
funcLike(id);
});