单击附加并将div的一部分替换为另一个div

时间:2016-03-22 16:50:03

标签: jquery

我有一个小提琴设置,我只是学习并对如何使这项工作感到困惑。

https://jsfiddle.net/twxxwj1m/6/

当我点击任何文字"选择"它打开一个隐藏的容器,其中包含我希望能够添加到容器的名称,我只需单击"选择"从。所以,如果我点击"选择"盒子容器中的文字标记为QB - 选择四分卫,然后会打开一个新框,列出要添加的几个玩家,我想点击"添加"在任何这些框中,我想从可用列表中删除该div并将其添加到起始列表中,而不是我最初选择的位置。我很困惑,甚至可能更难以描述这个。

$("#available-players .quarterbacks").hide();
$("#available-players .runningbacks").hide();
$("#available-players .widereceivers").hide();
$("#available-players .tightends").hide();
$("#available-players .flex").hide();
$("#available-players .defense").hide();
$("#available-players h1").hide();

$(".quarterbacks .show-players").click(function(){
    $("#starting-players").hide();
    $("#available-players .quarterbacks,#available-players h1").show();
});
$(".runningbacks .show-players").click(function(){
    $("#starting-players").hide();
    $("#available-players .runningbacks,#available-players h1").show();
});
$(".widereceivers .show-players").click(function(){
    $("#starting-players").hide();
    $("#available-players .widereceivers,#available-players h1").show();
});
$(".tightends .show-players").click(function(){
    $("#starting-players").hide();
    $("#available-players .tightends,#available-players h1").show();
});
$(".flex .show-players").click(function(){
    $("#starting-players").hide();
    $("#available-players .flex,#available-players h1").show();
});
$(".defense .show-players").click(function(){
    $("#starting-players").hide();
    $("#available-players .defense,#available-players h1").show();
});


$(".quarterbacks .add-players").click(function(){
    $("#available-players .quarterbacks,#available-players h1").hide();
    $("#starting-players").show();
});
$(".runningbacks .add-players").click(function(){
    $("#available-players .runningbacks,#available-players h1").hide();
    $("#starting-players").show();
});
$(".widereceivers .add-players").click(function(){
    $("#available-players .widereceivers,#available-players h1").hide();
    $("#starting-players").show();
});
$(".tightends .add-players").click(function(){
    $("#available-players .tightends,#available-players h1").hide();
    $("#starting-players").show();
});
$(".flex .add-players").click(function(){
    $("#available-players .flex,#available-players h1").hide();
    $("#starting-players").show();
});
$(".defense .add-players").click(function(){
    $("#available-players .defense,#available-players h1").hide();
    $("#starting-players").show();
});

到目前为止,我所拥有的是最简单,最好的方法吗?

0 个答案:

没有答案