Skip to content Skip to sidebar Skip to footer

How To Prevent Onclick Event On A Div While Clicking On Body Click?

I would like to do functionality for body,html elements while clicking on anywhere on document and also there is a div tag which is onclick event will be there. Both are clashing e

Solution 1:

jQuery(document).on('click','body',function(event){
    event.preventDefault();
    event.stopPropagation();
     var finding_span;
    finding_span = $jd(".design-area").find('.content-inner span.drag-item');

     if(finding_span.length>0){
        design.item.unselect();
    }

Hope this may help you

Solution 2:

Try the following

$jd(function(){
       event.preventDefault();
       event.stopPropagation();
       $jd('.menu-left a').click(function(){
       $jd('.menu-left a').removeClass('active');          
        if($jd(this).hasClass('add_item_team')) self.team.create();
        if($jd(this).hasClass('add_item_qrcode')) self.qrcode.open();
        $jd(this).addClass('active');
        jQuery("#text-lock").trigger("click");
     });
   });

Solution 3:

jQuery(document).on('click','html,body,#main',function(event){
 event.preventDefault();
    event.stopPropagation();


    if(event.target.id=="text-lock"){
        returnfalse;

    }

     var finding_span;
    finding_span = $jd(".design-area").find('.content-inner span.drag-item');

     if(finding_span.length>0){
        design.item.unselect();

        jQuery(".add_item_text").css({'background-color':'#f6f6f6','color':'#333'});
    }

Post a Comment for "How To Prevent Onclick Event On A Div While Clicking On Body Click?"