如何在jquery事件中访问event.target?

时间:2014-10-27 06:18:21

标签: javascript jquery html css angularjs

我有以下angularJS markeup:

<article ng-controller="GalleryListCtrl">
<details ng-repeat="gallery in galleries" gallery-repeat-directive>
    <summary>{{gallery.name}}</summary>
    <div class="image-gallery">
        <div ng-repeat="child in gallery.children">
            <img src="/Album/Image/{{gallery.name}}/Thumbnail/{{child}}" onclick="previewImage(this);" />
        </div>
    </div>
</details>

当这个标记加载时,我有一个隐藏div的事件:

var stephensApp = angular.module('stephensApp', ['ngResource', 'ngSanitize'])
.directive('galleryRepeatDirective', function ($timeout) {
    return {
        link: function (scope, element, attr) {
            if (scope.$last === true) {
                $timeout(function () {
                    scope.$emit('ngRepeatFinished');
                });
            }
        }
    }
});

在事件处理程序中,我有以下代码:

    $scope.$on('ngRepeatFinished', function (ngRepeatFinishedEvent) {
    if (! isChrome()) {
        $('details div:first-of-type').hide();
        $('details').bind('click', function (event) {
            console.log(event);
            $(event.target).find('div').first().show();
        });
    }
});

在我的Firefox浏览器中,我正在正确隐藏div,但是当我单击详细信息时,日志条目会写入调试器,因此我知道该事件正在触发。但我不能再做div节目了。如何找到点击详细信息标记的div?

0 个答案:

没有答案