这是我的输入字段,我想在此字段中只为数字关键字类型设置j查询代码。如果用户输入字符串,则无法执行此操作。
//init map and set options
var gmap = new google.maps.Map(map_canvas, map_options);
var thePanorama = gmap.getStreetView();
// change view
google.maps.event.addListener(thePanorama, 'visible_changed', function() {
// Display your street view visible UI
if (thePanorama.getVisible()) {
var panorama = new google.maps.StreetViewPanorama(
map_canvas, {
addressControlOptions: {
position: google.maps.ControlPosition.BOTTOM_CENTER, // <- change position
}
});
// rewrite default options
gmap.setStreetView(panorama);
} else {
console.log('show default UI');
}
});
答案 0 :(得分:2)
你去吧
comment1
comment2
comment3
comment4
comment5
comment6
答案 1 :(得分:2)
检查一下,它只允许文本字段中的数字
$(function() {
$('#main').on('keydown', '#onlyNumbers', function(e){-1!==$.inArray(e.keyCode,[46,8,9,27,13,110,190])||/65|67|86|88/.test(e.keyCode)&&(!0===e.ctrlKey||!0===e.metaKey)||35<=e.keyCode&&40>=e.keyCode||(e.shiftKey||48>e.keyCode||57<e.keyCode)&&(96>e.keyCode||105<e.keyCode)&&e.preventDefault()});
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<div id="main">
<input id="onlyNumbers" type="text" />
</div>