I want to run jquery code when i click on a button.
我想点击按钮时运行jquery代码。
This is my jquery code:
这是我的jquery代码:
<script src="scripts/jquery-1.4.1.js"></script>
<script type ="text/javascript" >
$(document).ready(function () {
$('#searchtextbtn').click(function () {
alert("Hello");
});
});
</script>
And my html looks like:
我的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>
But here when i click on the button nothing happens.
但是当我点击按钮时没有任何反应。
This is the page once I run my project:
这是我运行项目后的页面:
When I click on the "Location Master" link, partial view will be displayed like this:
当我点击“Location Master”链接时,部分视图将显示如下:
which contain search button.
其中包含搜索按钮。
1 个解决方案
#1
1
Add the following CDN to your code
将以下CDN添加到您的代码中
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
</head>
#1
1
Add the following CDN to your code
将以下CDN添加到您的代码中
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
</head>