小编jez*_*ama的帖子

如何判断当前是否选择了 Google 地图标记?

我在 Google Maps V3 上有一个足够简单的地图。

我在鼠标悬停侦听器事件上更改图标图像,在鼠标移出时将其更改回来,非常简单。

单击标记时,我再次更改图标,但是,我想在选择标记时保留该图标。当我将鼠标移开时,标记图标再次发生变化,因为我告诉它在鼠标移出侦听器事件中这样做。

我需要从 mouseout 侦听器事件中排除所选标记,但我不知道如何找到当前选择的标记。有任何想法吗?

这是我的代码

            google.maps.event.addListener(marker, 'mouseover', function () {
                this.setIcon("images/star-3-white.png");

            });
            google.maps.event.addListener(marker, 'mouseout', function () {
                    //  this overwrites the image again, 
                    //  need to exclude the current one here
                    this.setIcon("images/star-3.png");
            });

            google.maps.event.addListener(marker, 'click', function () {
                this.setIcon("images/star-3-white.png");
                infowindow.setContent(this.html);
                infowindow.open(map, this);
            });
Run Code Online (Sandbox Code Playgroud)

google-maps google-maps-api-3

5
推荐指数
1
解决办法
1万
查看次数

将jQuery click事件分配给除了几个div及其子项之外的正文中的所有内容

当我在页面上按div时,会出现一个弹出窗口.再次单击div时,弹出窗口消失.当您点击div外部时,弹出窗口消失 - 到目前为止看起来都很好看.

问题是,当我点击弹出窗口时,我想要弹出窗口和它的子窗口是可点击的(它们是无序列表中的链接).但是,我似乎无法让它发挥作用.这是我的代码

        $(function () {
            $('#messageNotification').click(function (event) {
            $("body").one('click', function () {

                jQuery(".userInfo").fadeOut();
            });
            event.stopPropagation();
        });


          <body>
            <div id="messageNotification"><div class="notif same">0</div></div>
            <div id="messages">
                <ul class="userInfo" style="">
                    <li></li>
                </ul>
            </div>

          </body>
Run Code Online (Sandbox Code Playgroud)

jquery javascript-events

4
推荐指数
1
解决办法
3702
查看次数