点击事件在谷歌浏览器中不起作用

时间:2013-11-12 08:54:47

标签: javascript jquery ajax

在这里我把我的代码放在我有一个ajax触发数据表中的下拉单击事件,在我的ajax我写了tableid点击该特定字段classname它在firefox中工作正常但在谷歌chrome中没有工作。我使用1.7.min.js我用它来我的所有页面当我改变它整个代码将崩溃所以我不能改变js。我的代码在这里是ajax

<script type="text/javascript">

function action()
{
    jQuery('#dyntable').on('click','.quickview',(function()
    {
        //show all hidden row and remove all showed data
        jQuery(this).parents('table').find('tr').each(function()
        {
            jQuery(this).removeClass('hiderow');
            if(jQuery(this).hasClass('togglerow'))
                jQuery(this).remove();
       });

        var parentRow = jQuery(this).parents('tr');
        var numcols = parentRow.find('td').length + 1;          //get the number of columns in a table. Added 1 for new row to be inserted



        //this will insert a new row next to this element's row parent
        parentRow.after('<tr class="togglerow"><td colspan="'+numcols+'"><div class="toggledata"></div></td></tr>');

        var toggleData = parentRow.next().find('.toggledata');

        parentRow.next().hide();

        var qty =  jQuery(this).val();

        jQuery.ajax({   



              url: "ajax/tabledata.php?id="+jQuery(this).val(),

              success:function(data){
                   toggleData.html(data);
                   parentRow.next().fadeIn();   
                },  
                error: function(jqXHR, textStatus, errorThrown) {
                console.log('Error occured: ' + errorThrown);
            }   
          });

        /*var qty =  jQuery(this).val();            
        var url = "ajax/tabledata.php?id="+qty;

        //get data from server
        jQuery.post(url,function(data){
            toggleData.append(data);                        //inject data read from server
            parentRow.next().fadeIn();                      //show inserted new row
                                                            //hide this row to look like replacing the newly inserted row
        });*/

        return false;
    }));


    //for map view of dropdown

    jQuery('#dyntable').on('click','.showmap',(function()
    {
        //show all hidden row and remove all showed data
        jQuery(this).parents('table').find('tr').each(function()
        {
            jQuery(this).removeClass('hiderow');
            if(jQuery(this).hasClass('togglerow'))
                jQuery(this).remove();
       });

        var parentRow = jQuery(this).parents('tr');
        var numcols = parentRow.find('td').length + 1;          //get the number of columns in a table. Added 1 for new row to be inserted
        var qty =  jQuery(this).val();          
        var url = "Mapdashboard.php?id="+qty;


        //this will insert a new row next to this element's row parent
        parentRow.after('<tr class="togglerow"><td colspan="'+numcols+'"><div class="toggledata"></div></td></tr>');

        var toggleData = parentRow.next().find('.toggledata');

        parentRow.next().hide();

        //get data from server
        jQuery.post(url,function(data){
            toggleData.append(data);                        //inject data read from server
            parentRow.next().fadeIn();                      //show inserted new row
                                                            //hide this row to look like replacing the newly inserted row
        });

        return false;
    })); 


}

</script>

1 个答案:

答案 0 :(得分:0)

从中删除括号:

 jQuery('#dyntable').on('click','.showmap',(function(){...});

To :

  jQuery('#dyntable').on('click','.showmap',function(){...});