javascript - How to use CSS on autocomplete textbox selected values -
every time client select item autocomplete textbox, automaticly appears in div created right under textbox. style css each selected item appears in div, , not whole div. example, want every selected item appear black border. (i use css on div, i'll border whole div , not on each item selected).
that's js code. need add css new selected country.
$(function() { /* textbox id */ $("#destinations").autocomplete({ select: function (event, ui) { /* div id */ $("#destinationschosen").html(function(i, origtext) { var selectedcountry = ui.item.value.tostring(); var currenttext = origtext.tostring(); if ((currenttext.indexof(selectedcountry) >= 0)) { alert("already exists"); return currenttext; } return currenttext + " " + selectedcountry; }) } }); })
here whole code: http://jsfiddle.net/3zfcb04k/
change this:
return currenttext + " " + selectedcountry;
to this:
return currenttext + " <span>" + selectedcountry + "</span><br/>";
then apply css on span
tag.
Comments
Post a Comment