I'm creating a search bar using jQuery and my code is pasted below
Fiddle : https://jsfiddle.net/fpLf1to4/
var inputSearch = $('.searchInput').hide();
var searchArray = ['s','e','a','r','c','h'];
var searchReturn = '';
$('#search').on('click', function(){
$(inputSearch).fadeToggle(500).focus();
for(var i = 0 ; i < searchArray.length ; i++){
searchReturn = searchReturn + searchArray[i];
}
$(inputSearch).attr('placeholder', searchReturn[0]);
});
Note : now I'm using only the first index of the array for my input attribute.
$(inputSearch).attr('placeholder', searchReturn[0]);
Now after every one second I want my attr() to be updated like
$(inputSearch).attr('placeholder', searchReturn[0] + searchReturn[1]);
and the very next second
$(inputSearch).attr('placeholder', searchReturn[0] + searchReturn[1] + searchReturn[2]);
and so on ...