i wnt to swap image on click,bt here if m clicking from down image to up but again its not coming on down image if m clicking on that image…
m geting some error-x.attr(“src”) is undefined
$(document).ready(function () {
$('#sortdivlink').click(function () {
var x = $("img[src$='../Images/Sort_down.png'][name='stCodeDSC']");
if (x.attr("SRC") == "../Images/Sort_down.png") {
x.attr('src', x.attr('src').replace("../Images/Sort_down.png", "../Images/sort_up.png"));
}
else {
x.attr('src', x.attr('src').replace("../Images/sort_up.png", "../Images/Sort_down.png"));
}
});
});
you could use a
<div>with a css class with abackground-imageand dimensions, and use $(div).toggleClass(“new-image”) to use the updatedbackground-imagethat will greatly simplify your code.
[EDIT]