Jquery不适用于按钮单击

时间:2015-12-22 09:41:28

标签: c# jquery html asp.net-mvc-4

我想在点击按钮时运行jquery代码。

这是我的jquery代码:

<script src="scripts/jquery-1.4.1.js"></script>
<script type ="text/javascript" >   
 $(document).ready(function () {
    $('#searchtextbtn').click(function () {
        alert("Hello");
    });
});
</script>

我的HTML看起来像:

<body>
<div id="content_inner">
    <div class ="page_header">
          <h2>Location Master</h2>
        <div id="search">
            <table  width="100%">
                <tr>
                    <td align="left">
                         <font color="#AFBECF">@Html.Label("Search")</font>
                    </td>
                    <td>  

                       <input  id="searchtextbtn" type="submit" value="search">
                <input  id="searchtextbtn" type="button" value="search"> @*not woring*@

                    </td>
                </tr>
            </table>
    </div></div></div>

但是当我点击按钮时没有任何反应。

这是我运行项目后的页面:

enter image description here

当我点击“Location Master”链接时,部分视图将显示如下:

enter image description here

包含搜索按钮。

1 个答案:

答案 0 :(得分:1)

将以下CDN添加到您的代码中

<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
</head>
相关问题