$(function(){ $len = $("#flash").find(".ad").length; $("#next").click(function(){ $(".ad").each(function(){ $state = $(this).css("display"); if($state=="block"){ $this = $(this); } }); if($this.next().html()==""){ $this.hide(); $this = $(".ban01"); $(".ban01").show(); $id_name = $this.attr("id"); var pre = /\d/; var metches = pre.exec($id_name); $new_id = metches[0]; $("#f"+$new_id).attr("class","dq"); $("#f"+$new_id).siblings().attr("class","no"); }else{ $this.hide().next().show(); $id_name = $this.next().attr("id"); var pre = /\d/; var metches = pre.exec($id_name); $new_id = metches[0]; $("#f"+$new_id).attr("class","dq"); $("#f"+$new_id).siblings().attr("class","no"); } }); $("#prev").click(function(){ $(".ad").each(function(){ $state = $(this).css("display"); if($state=="block"){ $this = $(this); } }); if($this.prev().html()==""){ $this.hide(); $this = $(".ban03"); $(".ban03").show(); $id_name = $this.attr("id"); var pre = /\d/; var metches = pre.exec($id_name); $new_id = metches[0]; $("#f"+$new_id).attr("class","dq"); $("#f"+$new_id).siblings().attr("class","no"); }else{ $this.hide().prev().show(); $id_name = $this.prev().attr("id"); var pre = /\d/; var metches = pre.exec($id_name); $new_id = metches[0]; $("#f"+$new_id).attr("class","dq"); $("#f"+$new_id).siblings().attr("class","no"); } }); })