如何使用javascript模拟鼠标点击(在谷歌地图中)?

如何使用javascript模拟鼠标点击(在谷歌地图中)?,javascript,jquery,html,css,google-maps,Javascript,Jquery,Html,Css,Google Maps,这里,我有一个简单的谷歌本地搜索API和谷歌地图代码 如何使我在单击搜索结果的标题时模拟地址的单击?我的目标是通过单击标题使弹出框出现在地图上。我把它绑在这上面: $(".gs-title").click(function(){ //SIMULATE MOUSE CLICK of the address HERE $(this).parent().parent().find(".gs-address").click(); // this doesn't work!!

这里,我有一个简单的谷歌本地搜索API和谷歌地图代码

如何使我在单击搜索结果的标题时模拟地址的单击?我的目标是通过单击标题使弹出框出现在地图上。我把它绑在这上面:

$(".gs-title").click(function(){

    //SIMULATE MOUSE CLICK of the address HERE
    $(this).parent().parent().find(".gs-address").click(); // this doesn't work!!

    alert("the title was clicked!!"); //this works fine.
    return false; //this also works fine. The hyperlink gets disabled because I returned false.

});

我希望能够点击标题,而不是打开链接。然后,弹出地图上的方框。换句话说,我想把结果作为一个整体来处理。

Html代码是:

    <div class="gs-title"><a target="_blank" class="gs-title" href="http://www.google.com/maps/place?source=uds&amp;q=pizza&amp;cid=12855512876323852687">California <b>Pizza</b> Kitchen</a></div>

    <div class="gs-address">...

解决了。我手动删除了A标签

// Returns the HTML we display for a result before it has been "saved"
    LocalResult.prototype.html = function() {
      var me = this;
      var container = document.createElement("div");
      container.className = "unselected";
      container.appendChild(me.result_.html.cloneNode(true));
      $(container).find('a').replaceWith(function() { return $(this).contents(); });

      return container;
    }

你确定
$(this).parent().parent().find(“.gs address”)
确实找到了你认为它找到的东西吗?当我单击结果时,我确实看到它打开弹出窗口很好。但我也看到弹出窗口打开了。如果我只是单击地址区域而不是标题,那么它会满足您的要求。我缺少什么?我希望能够单击标题,而不是打开链接。然后,弹出地图上的方框。换句话说,我希望将结果作为一个整体来处理。当我添加return false时,链接不会打开。但是,现在已经没有弹出窗口了。忽略我以前的代码。我可以在当前脚本中添加什么,以便在单击标题时,弹出窗口出现,但新选项卡不会出现?我尝试了。但是由于某些原因,弹出信息没有显示出来?点击并没有真正激活弹出信息。不错,我想建议重写LocalResult.prototype.html,但这并不是那么简单:你的解决方案真的很糟糕:>eheheh
// Returns the HTML we display for a result before it has been "saved"
    LocalResult.prototype.html = function() {
      var me = this;
      var container = document.createElement("div");
      container.className = "unselected";
      container.appendChild(me.result_.html.cloneNode(true));
      $(container).find('a').replaceWith(function() { return $(this).contents(); });

      return container;
    }