这是创建数组并访问它们的代码。
<script>
$(document).ready(
function() {
var i;
var mycars = new Array();
mycars[0] = "Car1";
mycars[1] = "Car2";
mycars[2] = "Car3";
mycars[3] = "Car4";
var Car1 = {
ownerName: "Owner1",
phoneNumber: "phoneNumber1",
address: "Address1"
}
var Car2 = {
ownerName: "Owner2",
phoneNumber: "phoneNumber2",
address: "Address2"
}
var Car3 = {
ownerName: "Owner3",
phoneNumber: "phoneNumber3",
address: "Address3"
}
$("div#tabbable").tabs();
// $("button#add-tab").click(function() {
var num_tabs = $("div#tabbable ul li").length + 1;
for (i = 0; i < mycars.length; i++) {
$("div#tabbable ul").append(
"<li><a href='#tab" + num_tabs + "'>" + mycars[i]
+ "</a></li>");
$("div#tabbable").append(
"<div id='tab" + num_tabs + "'>#" + mycars[i] + "</div>"
); $("div#tabbable").tabs("refresh");
}
//});
});
</script>
<body>
<!-- needed for tabbable population -->
<div class="row-fluid">
<div class="span5 offset1">
<div id='tabbable'>
<ul class="nav nav-tabs nav-stacked">
<li>
<!-- <a href='#tab1'>#1</a> --></li>
</ul>
<!-- <div id='tab1'></div> -->
</div>
<!-- <button id='add-tab'>Add tab</button> -->
</div>
</div>
<!-- end -->
</body>
如果我需要每辆车的详细信息,例如如何制作一个依赖于 mycars 数组的数组,该怎么办。当我使用对象填充汽车详细信息时,如何在此代码中获取汽车的详细信息?单击填充的选项卡时如何获取这些汽车详细信息???