Li color based on condition

Bootstrap Typeahead is used for autosuggestion list based on type text in input.

I have customized this js and added more function, so that you can easily used this for multi purpose.

Li color based on condition

To change color of list element based on search content. I have added colour attribute for this.

$('#typeahead').typeahead({
   colour: "colourCondition"
});

Here coloutCondition is javascript function

function colourCondition(item, i) {
       if (item.type == 3) {
            i.addClass("color-brown"
       }
}

Download bootstrap-typeahead.js from github

Author: Jaydip Panchal

Hello, This is jaydip panchal here, who do code, dream code, eat code, drink code, walk code. #CodeWithJaydip #CodeWithGeek

Leave a Reply

Your email address will not be published. Required fields are marked *