<html>
<head>
<title>如何用jquery循环option的值</title>
<style>
</style>
<script src="jquery.js"></script>
<script type="text/javascript">
$(function(){
$("#submit").click(function(){
$("select[name=country] option:selected").each(function(){
if($(this).text()== "香港") {
//alert($(this).text());
alert("this is hongkong");
}
});
});
});
</script>
</head>
<body>
<form action="" method="post" name="form1">
产品名:<input type="text" name="pro" id="pro"><br/>
品牌型号:<input type="text" name="size" id="size"><br/>
省市:<select name="country" id="country">
<option value="0">香港</option>
<option value="1" selected="selected">台湾</option>
<option value="2">上海</option>
</select><span id="hao"></span><br/>
<input type="button" id="submit" value="提交">
</form>
</body>
</html>
res:选中香港的时候,弹出this is hongkong