Alex Rivera | Logout

Disable onclick function on image tag

Asked 2011-12-30T23:46:07.523
9

jQuery how can I disable a click on <img> tag

$("#ico_cal_id").attr('disabled', 'disabled') or
$("#img_id").attr('disabled', 'disabled') is not working

Below is my code:

<span id="img_id"><src="ico_calendar.png" id="ico_cal_id" style="cursor: pointer"; onlick="showCalendar(this,'startDay','startMonth','startYear');" /></span>

whenever I click on the calendar_image the calendar is popping up

Any ideas?

Edit
Report

2 Answers

12

Try this:

$("#ico_cal_id").prop("onclick", false);

More about prop() here.

answered 2011-12-30T23:49:26.230
1

Remove the onclick property?

$("#ico_cal_id")[0].onclick = null;

or:

$("#ico_cal_id").removeAttr("onclick");
answered 2011-12-30T23:48:55.323

Your Answer