2

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');
});

3 Answers 3

1
$("#signin").click(function(e) {
    e.preventDefault();
    $(this).attr("src", "images/icon.png");
});

.attr <- Function name is lowercase.

Sign up to request clarification or add additional context in comments.

Comments

1

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';
});

Comments

0

You have mis-spelled the function attr(). The Attr should be attr, javascript is case sensitive.

$("#signin").click(function (event) {
    event.preventDefault();
    alert("show data");
    $("#signin").attr('src', 'images/icon.png');
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.