<html> | |
<head> | |
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script> | |
<script type="text/javascript"> | |
$(document).ready(function(){ | |
$(".field").change(function(){ | |
$(this).css("background-color","#FFFFCC"); | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<p>在某个域被使用或改变时,它会改变颜色。</p> | |
Enter your name: <input class="field" type="text" /> | |
<p>Car: | |
<select class="field" name="cars"> | |
<option value="volvo">Volvo</option> | |
<option value="saab">Saab</option> | |
<option value="fiat">Fiat</option> | |
<option value="audi">Audi</option> | |
</select> | |
</p> | |
</body> | |
</html> | |