【问题标题】:Gmaps add an event to a link in a markerGmaps 将事件添加到标记中的链接
【发布时间】:2013-05-26 07:00:51
【问题描述】:

我有一个小问题

是否可以在 gmaps v3 中的标记中的链接中添加事件 CLICK?

var m = new google.maps.Marker({
    map: map,
    animation: google.maps.Animation.DROP,
    position: position,
    html: "<a id='link'>mylink</a>",
    icon: '/images/repairer.png'
});
gmarkers.push(m);

  $('#link').click(function () {    
          alert($(this).attr('data'));
    });

google.maps.event.addListener(m, 'click', function () {
 info_window.setContent(this.html);
 info_window.open(map, this);
});

帮助

【问题讨论】:

    标签: javascript jquery google-maps google-maps-markers infowindow


    【解决方案1】:
      $('#your_map_id').on('click', '#link',function () {    
              alert($(this).attr('data'));
        });
    

    【讨论】:

    • $('#service_center').on('click', '#OpenDetailsFromMarker'+gm,function () { alert($(this).attr('data')); }) ;不工作
    • @user2437305 试试$('#service_center').on('click', 'a',function () { alert($(this).attr('data')); }
    猜你喜欢
    • 2012-03-31
    • 1970-01-01
    • 1970-01-01
    • 2013-04-01
    • 2017-09-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-20
    相关资源
    最近更新 更多