Reputation: 43
i am not able to change image on clicking image in jquery pls see this
$("#signin").click(function (event) {
event.preventDefault();
alert("show data");
$("#signin").Attr('src', 'images/icon.png');
});
Upvotes: 2
Views: 159
Reputation: 1378
$("#signin").click(function(e) {
e.preventDefault();
$(this).attr("src", "images/icon.png");
});
.attr <- Function name is lowercase.
Upvotes: 1
Reputation: 32581
You need to change
.Attr
to
.attr
.Attr is not a function in jQuery, it's case sensitive.
Documentation : http://api.jquery.com/attr/
Note: You could use this.src
there is no need to use jQuery to change the source of the image
$("#signin").click(function (event) {
event.preventDefault();
alert("show data");
this.src= 'images/icon.png';
});
Upvotes: 1