我是学习代码的新手 - 所以请耐心等待。我正在尝试为我的妻子(她是一名学校老师)创建一个危险风格的游戏。但是,我遇到了一个问题。我想单击一个链接(100 美元等)并将线索(价值)登录到单独页面上的 div 中。通过我的研究,我决定从一个数组创建一个 JSON 对象,然后将 JSON 解析为索引和值。
这是我的 HTML:
<ul id="rowOne">
<li><a href="clueJ.html">$100</a></li>
<li><a href="clueJ.html">$100</a></li>
<li><a href="clueJ.html">$100</a></li>
<li><a href="clueJ.html">$100</a></li>
<li><a href="clueJ.html">$100</a></li>
</ul>
这是我希望记录值的 div:
<div id="clueContainer" class="center"></div>
这是我的jQuery:
$(document).ready(function(){
var rowOne = array [
{name:"$100", value:"On the world political map, where were some of the major states and empires located about 1500 A.D. (C.E.)?"},
{name:"$200", value:"What were the artistic, literary, and intellectual ideas of the Renaissance?"},
{name:"$300", value:"Where were the five world religions located around 1500 A.D. (C.E.)?"},
{name:"$400", value:"What were the regional trading patterns about 1500 A.D. (C.E.)?"},
{name:"$500", value:"Why were the regional trading patterns important?",}
];
var json = JSON.parse(rowOne);
$("li a href").click(function(){
$.each(json, function(index, value){
$("#clueContainer").append(function(){
$(value).log(<p>+value+</p>);
});
});
});
});
是否有任何想法或我以错误的方式接近这个项目?