【发布时间】:2013-05-03 06:35:33
【问题描述】:
这是动态生成的 ul,其中 google 建议显示为下拉菜单
<ul class="ui-autocomplete ui-menu ui-widget ui-widget-content ui-corner-all" role="listbox" aria-activedescendant="ui-active-menuitem" style="z-index: 1; top: -1734.72px; left: 105px; display: none; position: relative; width: 300px;">
<li class="ui-menu-item" role="menuitem">
<li class="ui-menu-item" role="menuitem">
<li class="ui-menu-item" role="menuitem">
<li class="ui-menu-item" role="menuitem">
<li class="ui-menu-item" role="menuitem">
<li class="ui-menu-item" role="menuitem">
<li class="ui-menu-item" role="menuitem">
<li class="ui-menu-item" role="menuitem">
</ul>
<ul class="ui-autocomplete ui-menu ui-widget ui-widget-content ui-corner-all" role="listbox" aria-activedescendant="ui-active-menuitem" style="z-index: 1; top: 0px; left: 0px; display: none;"></ul>
我想在输入文本框右侧的 div 中显示这些建议。
.ui-autocomplete {
background-color: #ccc;
width: 300px;
border: 1px solid #cfcfcf;
list-style-type: none;
padding-left: 0px;
margin-top:300px;
}
.ui-autocomplete li:hover {
background-color: white;
}
.ui-corner-all{
font-size:18px;
margin-top:300px;
}
margin 似乎不起作用,当我从建议列表中选择任何建议时,它也不会显示在输入字段中。
这个的java脚本代码-->
function initialize(){
//MAP
var latlng = new google.maps.LatLng(41.659,-4.714);
var options = {
zoom: 16,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"), options);
//GEOCODER
geocoder = new google.maps.Geocoder();
marker = new google.maps.Marker({
map: map,
draggable: true
});
}
jQuery(document).ready(function() {
initialize();
jQuery(function() {
jQuery("#address").autocomplete({
//This bit uses the geocoder to fetch address values
source: function(request, response) {
geocoder.geocode( {'address': request.term }, function(results, status) {
response(jQuery.map(results, function(item) {
return {
label: item.formatted_address,
value: item.formatted_address,
latitude: item.geometry.location.lat(),
longitude: item.geometry.location.lng()
}
}));
})
},
//This bit is executed upon selection of an address
select: function(event, ui) {
var location = new google.maps.LatLng(ui.item.latitude, ui.item.longitude);
marker.setPosition(location);
map.setCenter(location);
}
});
});
});
【问题讨论】:
-
你的代码在哪里?不是动态生成的。而你发布的代码是不够的。
-
哪个代码?我想在一个 div 中获取这个动态生成的 ul .. 有可能吗?
-
是的,有可能。如果您至少可以揭示动态生成代码的部分代码,我可以为您提供帮助。我的意思是显示用于此“ul”生成的 javascript 代码示例。
-
我贴了Javascript代码你可以看看:)
标签: javascript jquery css google-maps-api-3