62,046
社区成员
发帖
与我相关
我的任务
分享
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#Select1 option").each(function(){
alert($(this).attr("selected"))
})
})
</script>
</head>
<body>
<select id="Select1">
<option>1</option>
<option selected="selected">2</option>
</select>
</body>
</html>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="CSDNTestDemo._Default" %>
<!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 runat="server">
<title>Untitled Page</title>
<script src="jquery-1.4.2.js" type="text/javascript" language="javascript"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function(){
$("#ddlIsSunShi").change(function(){
$("#ddlIsSunShi option").each(function(){
if($(this).attr("selected") == true)
{
if($(this).val() == "yes")
{
$("#txtSunShiFei").css("display", "");
}
else
{
$("#txtSunShiFei").css("display", "none");
}
}
})
});
})
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<tr align="center">
<td align="right" style="height: 22px">
是否产生损失:
</td>
<td align="left" style="height: 22px">
<select id="ddlIsSunShi">
<option value="yes">是</option>
<option value="no">否</option>
</select>
</td>
</tr>
<tr align="center">
<td align="right">
损失费:
</td>
<td align="left">
<input id="txtSunShiFei" style="width: 180px;" title="请填写损失费" type="text" />
</td>
</tr>
</div>
</form>
</body>
</html>
用jquery的方法,文件时用jquery1.4.2