Selecting Links in Google Maps InfoWindows w/ jQuery
In my web app, I am using jQuery to select all the links on the开发者_高级运维 page and intercept where they go to so that I can switch to a different part of the page with AJAX. The problem is that some of these links are in InfoWindows (if that's what they're called) on a Google Map. For some reason the jQuery selector $('a') isn't selecting them. They're loaded at the same time that the page is (which is when $('a').click is called) and I don't see how they don't show up in the DOM. Any ideas?
I think that the content of the infoWindows is injected to the DOM programmatically, when the window is shown up, so the links are not present when you execute your selector.
Try to bind the click
event with live
:
$('a').live('click', function () {
// ..
});
The live
method works with event delegation, and it will work for all the anchors present in the document.
精彩评论