Jquery Gallery Image Search
Mon Jun 15 2020 11:52:16 GMT+0000 (Coordinated Universal Time)
Saved by
@Hamza
let images = document.getElementsByClassName('thumb-image');
$('#search_templates').keyup(function (e) {
let search = $('#search_templates').val().toLowerCase();
for (let i = 0; i < images.length; i++) {
let searchVal = images[i].getAttribute('data-search');
if (searchVal.toLowerCase().indexOf(search) > -1) {
images[i].style.display = "";
}else{
images[i].style.display = "none";
}
}
});
//#search_templates is input and each image has keywords in data-search="" attribute
content_copyCOPY
Comments