我交换了div。当我点击#inactive
ID时,#active-page
应该会消失,#inactive-page
应该会出现。此外,#active id
应该成为#inactive
id,反之亦然。我使用了质量为#inactive-page-swap
和#inactive-page
的质量为#active-swap
和#active
的质量为#inactive
的id {= 1}}。
问题是 - 当我点击#active-page
ID时,#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>
没有出现。
{{1}}
请帮帮我!!!
答案 0 :(得分: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 example