我在看Google提供的API,我需要将它翻译成jQuery,所以我做了。在谷歌的代码中,谷歌定义了创建的元素,但它的工作原理没有在jQuery手机中定义它们。我是编程新手,所以我不确定这是否重要?该代码在控制台日志中无误地运行,无需定义。为什么这些不需要在这里定义?
谷歌:
google.maps.event.addListener(panoramioLayer, 'click', function(photo) {
var li = document.createElement('li');
var link = document.createElement('a');
link.innerHTML = photo.featureDetails.title + ': ' +
photo.featureDetails.author;
link.setAttribute('href', photo.featureDetails.url);
li.appendChild(link);
});
的jQuery:
google.maps.event.addListener(panoramioLayer, 'click', function(photo) {
$(document.createElement("a")).html("photo.featureDetails.title + ': ' + photo.featureDetails.author");
$("a").attr("href", photo.featureDetails.url);
$("li").append("a");
});
由于您正在设置** ALL ** a标记和** ALL,因此您的jQuery不会工作得太好**代码中的li标签。 –