2015-12-22 66 views
1

我想在點擊按鈕時運行jQuery代碼。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

當我點擊「位置大師」鏈接,局部視圖會顯示這樣的:

enter image description here

其中包含搜索按鈕。

+0

請更改按鈕類型,以'button'然後'submit' –

+1

您有加入jQuery的文件? – Adil

+1

你的代碼工程:https://jsfiddle.net/3oz9myf4/,確保你有jQuery包含 –

回答

1

添加下面的CDN你的代碼

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