同じボタンを 2 回以上連続して押すと、次のスライド効果が機能しません。つまり、赤いボタンを選択してその色を表示し、もう一度赤を押してその色を非表示にします。3回目押しても効きません。赤を再び機能させるには、別の色を選択する必要があります。これはすべてのボタンで発生します。どうすればこれを止めることができますか? フィドルのデモ
// When the DOM is ready, initialize the scripts.
jQuery(function( $ ){
// Get a reference to the container.
var container = $( ".container" );
// Bind the link to toggle the slide.
$( "a" ).click(function( event ){
// Prevent the default event.
event.preventDefault();
var $this = $(this);
var $target = $("#target");
if ($target.attr("class") === $this.attr("data-color")) {
container.slideUp(500);
} else {
// Hide - slide up.
container.slideUp(500, function(){
$target.attr("class", $this.attr("data-color"));
// Show - slide down.
container.slideDown(500);
});
}
});
});