$("#search_input").autocomplete({
source: results,
select: function(e, i) {
$('#searchresultdata').text(i.item.value);
}
}).on("keyup change",function() {
var search_input = $(this).val();
if (search_input.length > 0 && search_input != "Begin typing to search...") {
$('#searchresultdata').text("RAWR");
}
$('#searchresultdata').text(search_input);
}
);
Thats my code for a search box (search_input). Basically, I just want it so that if the box is empty or contains “Begin typing to search…” to display RAWR, if not, show what was typed into the search_input
You are calling
.text(search_input);regardless of whether or not your condition matches.You need to put this into an
elsestatement: