0

我有交换div的。当我单击#inactiveid 时,#active-page应该消失并且#inactive-page应该出现。此外,#active id应该成为#inactiveid,反之亦然。我已经使用交换 id 的= >#inactive-page-swap和.#inactive-page#active-swap#active

问题是 - 当我点击#inactiveid 时,#active-page消失但#inactive-page没有出现。

<script>
$(document).ready(function(){
    $("#inactive").click(function(){
        $(#inactive).attr("id","active-swap");
        $("#active").attr("id","inactive");
        $("#active-swap").attr("id","active");
        $("#active-page").attr("id","inactive-page-swap",function(){
            $("#inactive-page").attr("id","active-page");
            $("#inactive-page-swap").attr("id","inactive-page");
        });
    });
});
</script>

请帮我!!!

4

1 回答 1

0

试试这个...

$(document).ready(function(){
    $("#inactive").click(function(){
        var id = $(this).attr('id');
        inactive = $('#inactive');
        active = $('#active');
        swap = $('#active-swap');
        inactive.attr('id', 'active-swap');
        active.attr('id', 'inactive');
        swap.attr('id', 'active');
        inactive = $('#active-page');
        inactivepage = $('#inactive-page');
        inactiveswap = $('#inactive-page-swap');
        $(inactive).attr("id","inactive-page-swap");
        $(inactivepage).attr("id","active-page");
        $(inactiveswap).attr("id","inactive-page");
    });
});

看到这个jsFiddle 例子

于 2013-03-23T14:22:05.203 回答