$(function(){ var list = $(".motto"); list.on('click', function(){ var now = $(this); var nowChild = now.children("ul"); var nowSpan = now.children("ul span"); nowChild.stop(true,false).slideToggle(); if(nowChild.hasClass("active")){ nowChild.addClass("noactive"); nowSpan.css('background-image', 'url(/image/sp/new/motto_1.png)'); nowChild.removeClass("active"); }else if(nowChild.hasClass("noactive")){ nowChild.addClass("active"); nowSpan.css('background-image', 'url(/image/sp/new/motto_2.png)'); nowChild.removeClass("noactive"); } }); });