var data = {'1': 'one data', '2': 'two data'}; //получившийся json из массива в php
$('button').click(function(){
var id = $(this).attr('id');
var value = data[id] ? data[id] : 'empty';
alert(value);
});
clearString = str => {
const trash = str.match(/(.)\1{1,}/g)
for(let o in trash) {
str = str.replace(trash[o], trash[o].substr(0,1)+'*')
}
return str;
}
console.log(clearString('aabc11d'))
$('.product-listing .four-cont').hover(function() {
var $img = $(this).find('.image img'),
cacheImg = $img.attr('src');
if($img.data('additionalImage')) {
$img.fadeOut(500, function() {
$img.attr('src', $img.data('additionalImage'));
$img.data('additionalImage', cacheImg);
$img.fadeIn(500);
});
}
});