为什么我无法选择pac-container
班。
我正在使用Google Places API
请参见以下pac-container
类的屏幕截图:-
尝试了什么:-
$(document).on('click', '.pac-container', function() {
alert('pac container class selected');
})
答案 0 :(得分:0)
我得到了这个问题的答案,实际上我在document.ready
内部调用了我的Jquery代码,但是我需要在Place Autocomplete
代码内部使用它。
Place Autocomplete
在加载有问题的我的自定义jquery之前被加载,但是自定义jquery应该与Place Autocomplete
一起加载。
现在将我的代码带入一个函数中:-
function ZipOrCityOnMobile() {
if ($(window).width() < 768) {
$('.m-search-close').hide();
$('[name="ZipOrCity"]').parents('li').removeClass('search-control-mobile');
$('.home-text').css('z-index', '9');
}
}
然后在Place Autocomplete
function initOfficeLocationAddLocationPicker() {
var input = document.getElementById('ZipOrCity');
var places = new google.maps.places.Autocomplete(input);
// Set country for us.
places.setComponentRestrictions({ 'country': ['us'] });
google.maps.event.addListener(places, 'place_changed', function () {
var address = AddressHepler(places.getPlace());
if (address.postal_code != null && address.postal_code != '' && address.postal_code != undefined) {
var CityStateandZipcode = address.locality.concat(', ', address.state, ', ', address.postal_code);
$("#ZipOrCity").val(CityStateandZipcode);
}
else if (address.locality != null && address.locality != '' && address.locality != undefined) {
var CityandState = address.locality.concat(', ', address.state);
$("#ZipOrCity").val(CityandState);
}
else {
$("#ZipOrCity").val(address.state);
}
ZipOrCityOnMobile();
});
}