jQuery Multiple Event Handlers - How to Cancel?

后端 未结 6 714
盖世英雄少女心
盖世英雄少女心 2020-12-12 23:42

I have two functions bound to a click event at two different times (using jQuery). The order in which they are fired is significant. They are firing in the correct order.

6条回答
  •  有刺的猬
    2020-12-13 00:36

    Thanks, unbind works for redefining functions.

      $(document).ready(function(){
            $("#buscar_mercaderia").click(function(){ alert('Seleccione Tipo de mercaderia'); 
       });
    $(".tipo").live('click',function(){
                if($(this).attr('checked')!=''){
                    if($(this).val()=='libro'){
                        $("#buscar_mercaderia").unbind('click');
                        $("#buscar_mercaderia").click(function(){  window.open('buscar_libro.php','Buscar Libros', 'width=800,height=500'); });
                    }else if($(this).val()=='otra'){
                        $("#buscar_mercaderia").unbind('click');
                        $("#buscar_mercaderia").click(function(){ window.open('buscar_mercaderia.php','Buscar Mercaderias', 'width=800,height=500');  });
                    }
                }
            })
    

提交回复
热议问题