<ul> <li id="0">冬瓜很好吃</li> <li id="1">西瓜不好吃</li> <li id="2">南瓜很好吃</li> <li id="3">苦瓜很好吃</li> <li id="4">傻瓜怎么吃</li> <li id="5">冬天的瓜很好吃</li> </ul> <input type="text" onkeyup="finds(this.value)"> <script type="text/javascript"> var s=""; function finds(v){ if(v!=s&&v!=""){ $("li").css("color","#000"); $("li:contains('"+v+"')").css("color","red"); s=v; } } </script>