读书人

新手求教一个简单的JS有关问题

发布时间: 2013-07-09 09:50:48 作者: rapoo

新手求教一个简单的JS问题

我不知道为什么我一选择就提醒我 if ($("ttt").value == "样机")对象缺失,求大神指点


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" ValidateRequest="false" Inherits="test._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script type="text/javascript">
function getYangJiInfo(obj) {


if ($("ttt").value == "样机") {

alert("请填写公司型号");

}

}



</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>test</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="ttt" runat="server" onchange="getYangJiInfo(this);"
>
<asp:ListItem Value="样机1">样机1</asp:ListItem>
<asp:ListItem>样机2</asp:ListItem>
<asp:ListItem>样机3</asp:ListItem>
<asp:ListItem>样机</asp:ListItem>
</asp:DropDownList>



<asp:TextBox ID="公司型号" runat="server"></asp:TextBox>
</div>

</form>
</body>
</html>


[解决办法]
敢问$这个是什么呢,你有这个方法吗?,也没见你有jQuery的引用,且jQuery应该是$("ttt").val()
[解决办法]
1. 引用jquery

2. if ($("#ttt").val() == "样机")

读书人网 >asp.net

热点推荐