1

jqueryuiswitchClassメソッドを使用しようとしています。現在、それはそのように機能します:

$("#top_section").switchClass( "top_section", "pt_figures", 300);

変更したいのは、だけを削除するのではなく、top_sectionすべてのクラスを削除してから追加したいpt_figuresです。

ここで動作します:

$("#close_icon").click(function() {
$("#top_section").removeClass();
$("#top_section").addClass( "top_section", 300);

setTimeout(function() {
  $('#images').empty();
}, 350);

});

しかし、ここではありません:

$("#pt_figures").click(function() {


$('#images').empty();

$('#images').css({
  paddingLeft: 150,
  paddingRight: 0
});
$('#controls').css({
  width:700,
  marginLeft:150
});
$('#info').css({
  width:660,
  marginLeft:150
});

var id = $(this).attr('id');

$("#info_header").load(id +"_header.txt");
$("#content_1").load(id +"_1.txt");
$("#content_2").load(id +"_2.txt");
$("#content_3").load(id +"_3.txt");


$("<img>", { src: "http://www.klossal.com/figures_doc.jpg" }).appendTo("#images"); 
$("<img>", { src: "http://www.klossal.com/figure_front.png" }).appendTo("#images"); 
$("<img>", { src: "http://www.klossal.com/figure_back.jpg" }).appendTo("#images");

$('html, body').animate({
  scrollTop: 0
}, 300);



$("#top_section").removeClass();
$("#top_section").addClass( "pt_figures", 300);


});
4

1 に答える 1

2

すべてのクラスを削除し、切り替えたいクラスを追加して、次のクラスに切り替えてみてください。

    $(#top_section).removeClass();
    $(#top_section).addClass('top_section');
    $(#top_section).switchClass('top_section', 'pt_figures', 300);

デモ

于 2012-11-26T23:28:10.723 に答える