scenario: I want to do an ajax call to update the image shown. Example: click to activate, click again to deactivate.
Now, the image can change correctly when clicking for the first time.
After that, if I click the img again, changes won't reflect anymore.
The reason, the onclick status still= yes How do I access the hyperlink element to rewrite the onclick part to onclick="update('7', 'no') at REFER HERE?
<a href="#" onclick="update('7','yes')" ><img id=img7 border=0 src="img/active.gif" ></a>
<script type="text/javascript">
function update(pk, enable) {
$.ajax({
url: "ajaxcall.asp",
type: "POST",
success: function (output) {
var status = output
if (status == 1) {
var src = ($('#' + 'img' + pk).attr("src") == "img/cross.gif") ? "img/tick.gif" : "img/cross.gif";
$('#' + 'img' + pk).attr("src", src);
//REFER HERE
}
},
complete: function () { },
data: 'pk=' + pk + '&enable=' + enable
});
}
</script>