在 JQuery 中为 ASP 引用 bootstrap class 生成 HTML

Referencing bootstrap class in JQuery for ASP generated HTML

我的页面使用 ASP (VBScript) 在成功 SQL 提交后生成带有 bootstrap class 'alert' 的 div。我想要发生的事情是这样的——一旦用户提交表单并出现警报 div,然后他们单击表单的第一个输入字段,我希望警报 div 消失。我感觉问题在于:

A.) 引用 ASP 在 JQuery 中生成的 div B.) 用多个 bootstrap class 引用一个 div C.) 也许我正在打破一些大家都知道但我不知道的黄金法则。

如有任何帮助,我们将不胜感激。代码如下:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script>

$(function(){
$("qName").click(function(){
    $(".alert").hide();
});
});

</script>

</head>
<body>
<!-- #include virtual="/navbar.asp" -->
<section>
    <div class='container'>
        <div class='row well well-lg'>
            <% 
                If intStatus = 1 Then
                    Response.Write("<div class='alert alert-success'><h3 class='text-center'>Entry Successful!</h3></div>")
                ElseIf intStatus = 2 Then
                    Response.Write("<div class='alert alert-warning'><h3 class='text-center'>This query name already exists! Would you like to update the existing entry?</h3></div>")
                End If  
            %>
            <div class='text-center'>
                <h3>SQL Query Entry</h3>
                <i>Add SQL statements to be used by the Query Search Web Tool.</i><br>
            </div><br>
            <form method="post" action="/webtools/queryadd.asp" class="form-horizontal" role="form" id="reportform">
                <div class="form-group">
                    <label class="control-label col-sm-offset-2 col-sm-3" for="qName">Query Name: </label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control" id="qName" name="qName" placeholder="Enter Query Name (60 char max)" <% If intStatus = 0 Then %>value="<%=Request.form("qName") %>"<% End If %> maxlength="60" required>
                    </div>
...........................................

您需要使用 # 通过 ID 引用元素

$("qName").click(function(){

应该是

$("#qName").click(function(){