jquery 输入框提示

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
</head>
<style type="text/css">
.chosed { background:red;color:white}
</style>
<body>
<input type="text" name="" value="" />
<div>extension</div>
<div>endeavor</div>
<div>substr</div>
<div>tip</div>
<script type="text/javascript">
$('input').on("keyup change",function(){ 
var vals=$(this).val();
$('div').removeClass('chosed');
$('div:contains('+vals+')').addClass('chosed');
})
$("input").keyup(function(){
  $("input").css("background-color","#D6D6FF");
});
</script>
</body>
</html>

你可能感兴趣的:(输入框提示)