0
我得到li
元素的id
,并且想要使用该名称来访问对象的该部分。我试图添加包含我想要的部分的名称的var selectionId
,例如cars
,但出现错误。有没有办法?将字符串传递到对象javascript
谢谢。
$(document).ready(function() {
$(".markerSelection").click(function() {
var selectionId = $(this).attr("id");
drop(selectionId);
});
});
var markers = {
shopping : [
new google.maps.LatLng(52.26183, -7.11339),
new google.maps.LatLng(52.26134, -7.11226),
new google.maps.LatLng(52.26067, -7.11181),
new google.maps.LatLng(52.26003, -7.11033)],
cars : [
new google.maps.LatLng(52.26183, -7.11339),
new google.maps.LatLng(52.26134, -7.11226),
new google.maps.LatLng(52.26067, -7.11181),
new google.maps.LatLng(52.26003, -7.11033)]
};
var iterator = 0;
function drop(selectionId) {
clearOverlays();
for (var i = 0; i < markers.selectionId.length; i++) {
setTimeout(function() {
addMarker();
}, i * 200);
}
}
什么downvote? -innocent halo- * [可能会或可能没有删除downvote由于曲解答案] * – 2012-07-14 22:18:28
谢谢:D删除我的评论 – Hamish 2012-07-14 22:19:01
不客气。实际上,+1是正确的。 – 2012-07-14 22:19:20