有梦想日
答案 0 :(得分:3)
$("input").change(function(){
// do something
});
Click here了解更多信息。
答案 1 :(得分:0)
尝试此代码,
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="../jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("select").change(function () {
var str = "";
$("select option:selected").each(function () {
str += $(this).text() + " ";
});
$("div").text(str);
})
.change();
});
</script>
<style>
div { color:red; }
</style>
</head>
<body>
<select name="sweets" multiple="multiple">
<option>Chocolate</option>
<option selected="selected">Candy</option>
<option>Taffy</option>
<option selected="selected">Carmel</option>
<option>Fudge</option>
<option>Cookie</option>
</select>
<div></div>
</body>
</html>