我使用在这个问题中找到的代码来帮助我在页面上显示内联下拉菜单。不过,我需要将其中四个放在一个页面上,而且它们都将使用相同的教学策略列表。我已经尝试了我能想到的一切,例如为第二个菜单重命名所有元素,但没有运气。
我知道这可能很容易而且很明显,但我不明白。我可能正在改变我不应该改变的事情。我对 javascript 和 jquery 很陌生(尽管多年来一直在使用 HTML、CSS 和一点 PHP),虽然我通常可以很好地掌握一些东西,但像这样的简单事情让我陷入了困境。
这是我此时的代码:http: //jsfiddle.net/8npjQ/
<script type='text/javascript' src='http://code.jquery.com/jquery-1.6.4.js'></script>
<div id="somecontent"><span id="sort" href="#">Click for Strategies</span></div>
<div id="pop">
<div class="link" data-sort="dq1-1" >DQ1-1: Providing Clear Learning Goals and Scales (Rubrics)</div>
<div class="link" data-sort="dq1-2">DQ1-2: Tracking Student Progress</div>
<div class="link" data-sort="dq1-3">DQ1-3: Celebrating Success</div>
<div class="link" data-sort="dq6-4">DQ6-4: Establishing Classroom Routines</div>
<div class="link" data-sort="dq6-5">DQ6-5: Organizing the Physical Layout of the Classroom</div>
<div class="link" data-sort="dq2-6">DQ2-6: Identifying Critical Information</div>
<div class="link" data-sort="dq2-7">DQ2-7: Organizing Students to Interact with New Knowledge</div>
<div class="link" data-sort="dq2-8">DQ2-8: Previewing New Content</div>
<div class="link" data-sort="dq2-9">DQ2-9: Chunking Content into "Digestible Bites"</div>
<div class="link" data-sort="dq2-10">DQ2-10: Processing of New Information</div>
<div class="link" data-sort="dq2-11">DQ2-11: Elaborating on New Information</div>
<div class="link" data-sort="dq2-12">DQ2-12: Recording and Representing Knowledge</div>
<div class="link" data-sort="dq2-13">DQ2-13: Reflecting on Learning</div>
</div>
<script type="application/javascript">
var $menu = $('#pop');
$('#sort').click(function(e) {
$menu.css({
"left": e.offsetX + "px",
"top": e.offSetY + "px"
}).show();
});
$('#pop .link').click(function(e) {
var ele = $(this);
var sortKey = ele.attr('data-sort'); // save it somewhere
$('#sort').html(ele.html()
);
$menu.hide();
});
</script>
<style type="text/css">
#sort{
color: black;
border-bottom: 1px dotted blue;
}
#pop2{
color: #444;
width: 205px;
border: 1px solid #ccc;
padding: 5px;
display: none;
position: absolute;
line-height:140%;
background:#FFFFFF;
}
.link:hover {
color: red;
cursor: pointer;
}
</style>
任何和所有的帮助表示赞赏!