javascript - I want to disabled onClick event for image inside div onClick function? - Stack Overflow

I want to disable click event for image using image id eg. for id12 i want to disabled click event . i

I want to disable click event for image using image id eg. for id12 i want to disabled click event . i tried using unbind but it seems it only works if event is binded using j query?

I want to disable click event for image using image id eg. for id12 i want to disabled click event . i tried using unbind but it seems it only works if event is binded using j query?

Share Improve this question edited May 24, 2013 at 13:44 KhAn SaAb asked May 24, 2013 at 13:16 KhAn SaAbKhAn SaAb 5,3766 gold badges34 silver badges54 bronze badges 3
  • You can try this, onclick="return false;" – Satpal Commented May 24, 2013 at 13:19
  • unbind should work for any events; additionally try off for newer Query versions – feeela Commented May 24, 2013 at 13:19
  • are i have div on click of Div inside click function i want to disable image click event – KhAn SaAb Commented May 24, 2013 at 13:21
Add a ment  | 

6 Answers 6

Reset to default 7
$("#id12").on('click',function(e){
  e.preventDefault();
});
$("#id12").on('click',function(){
  return false;
});
$("#id12").click(function () { return false; });

$("#id12").on('click',function(e){ e.preventDefault(); });

    $("#id12").on('click',function(e){
       e.preventDefault();
    });

Below is pure javascript code. Try this :

document.getElementById('id12').setAttribute("onclick", null);

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745136592a4613230.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信