Reputation: 1550
This is my code:
/// <reference path="../jquery-1.5.1.js" />
jQuery(function($){
$(".deleteLink").click(function () {
alert(1);
});
});
$(".deleteLink").click(function () {
alert(2);
});
This is my link:
<a class="deleteLink" data-ajax="true" data-ajax-mode="replace" data-ajax-update="#1" href="/Admin/Delete?deleteID=1&unDelete=1" id="1">Delete</a>
In both cases whenever i press on the link no alert pops up.
Here are my links in the html file:
update:
<script src="@Url.Content("~/Scripts/jquery-1.5.1.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/AdminScript/AdminMenu.js")" type="text/javascript"></script> //External file where I execute my javascript/jquery code
Upvotes: 0
Views: 167
Reputation: 645
Try this,
$(function(){
$('.deleteLink').click(function(){
alert('Hello world');
});
});
Upvotes: 0
Reputation: 146191
$(document).ready(function(){
$(".deleteLink").click(function () {
alert(1);
return false;
});
});
Upvotes: 0
Reputation: 13673
The first part of your code uses an incorrect identifier to access jQuery.
Try replacing $jQuery
with either jQuery
or $
.
$(function(){
$(".deleteLink").click(function () {
alert(1);
});
});
The second bit probably fails because you put it in the header. This code is executed immediately so if you put that in the header of the html the specified link doesn't exist yet.
Upvotes: 5