event problem in Firefox

前端 未结 1 1744
既然无缘
既然无缘 2020-12-21 07:29

I have a problem accessing the \'event\' in Firefox. The following code works fine in Chrome, but in Firefox I get a \"event is not defined\" error.



        
相关标签:
1条回答
  • 2020-12-21 07:42

    Try this instead:

    function rowSelected(event, type) {
        var eventRow = event.currentTarget; // here I get the error
    }
    

    You where not allowing the event argument to be passed. Well, you were but it was being passed into the type variable. Now event will contain the currentTarget value.

    EDIT

    Oh wait! You wish to pass the row type too.

    This should do it!

    <tr onclick="rowSelected(event, 'thisRowType')">
      ... row content ...
    </tr>
    
    <script type="text/javascript">
        function rowSelected(event, type) {
            var eventRow = event.currentTarget; // here I get the error
            alert(type);
        }
    </script>
    
    0 讨论(0)
提交回复
热议问题