我想要練習這個任務的基礎知識。選擇李,根據選擇複製到另一個ul - jQuery
我的任務列表,當你點擊一個任務,選擇顯示(這是基於人們在html)
你選擇一個人,然後將任務添加到人微升。
這是我到目前爲止有: 小提琴有更多的評論: http://jsfiddle.net/GavinSteele/Cfyjc/
<ul></ul>
任何幫助將是巨大的..代碼,或在其任務先做只是方向。
// Click on a task
// Show select with peoples names
// Select a person
// Task is added to that persons ul
$(document).ready(function() {
// populate the select with options
$(".person h4").each(function() {
var optionTexts = [];
optionTexts.push($(this).text());
$('<option>').val(optionTexts).text(optionTexts).appendTo('select');
});
// Get the selected person
var selected = $('select :selected').text();
// Get the HTML of the task selected to append to the persons list
$("#original li").click(function(){
var html = $(this)[0].outerHTML;
$("select").removeClass("hidden");
$(html).appendTo(// THE SELECTED PERSONS LIST);
});
});
'$(this).clone(true).appendTo(...)'?不要使用'outerHTML' – Bergi
你有什麼問題?這似乎是一個爲我做的 –
嗨,感謝您的答覆,對不起,這不是一個爲我做的職位。我只需要方向上的幫助。不必爲代碼,也許只是,爲什麼你做到了這一點..試試這個..謝謝@Bergi多數民衆贊成在我需要的東西 – user1340971