// *** TAB *** // $(function(){ $(".tab li").click(function(){ var index = $(this).parent("ul").children("li").index(this); $(this).siblings("li").removeClass("active"); $(this).addClass("active"); $(this).parent("ul").nextAll(".panel").hide(); $(this).parent("ul").nextAll(".panel").eq(index).show(); }); }) // *** Page Top *** // $(document).ready(function() { $("#back-top").hide(); $(function () { $(window).scroll(function () { if ($(this).scrollTop() > 100) { $('#back-top').fadeIn(); } else { $('#back-top').fadeOut(); } }); }); // #で始まるアンカーをクリックした場合に処理 $('a[href^=#]').click(function() { // スクロールの速度 var speed = 400; // ミリ秒 // アンカーの値取得 var href= $(this).attr("href"); // 移動先を取得 var target = $(href == "#" || href == "" ? 'html' : href); // 移動先を数値で取得 var position = target.offset().top; // スムーススクロール $('body,html').animate({scrollTop:position}, speed, 'swing'); return false; }); }); // *** textcut *** // $(function(){ var $setElm = $('.cut'); var cutFigure = '18'; // カットする文字数 var afterTxt = ' …'; // 文字カット後に表示するテキスト $setElm.each(function(){ var textLength = $(this).text().length; var textTrim = $(this).text().substr(0,(cutFigure)) if(cutFigure < textLength) { $(this).html(textTrim + afterTxt).css({visibility:'visible'}); } else if(cutFigure >= textLength) { $(this).css({visibility:'visible'}); } }); var $setElm2 = $('.cut2'); var cutFigure2 = '40'; // カットする文字数 var afterTxt2 = ' …'; // 文字カット後に表示するテキスト $setElm2.each(function(){ var textLength = $(this).text().length; var textTrim = $(this).text().substr(0,(cutFigure2)) if(cutFigure2 < textLength) { $(this).html(textTrim + afterTxt2).css({visibility:'visible'}); } else if(cutFigure2 >= textLength) { $(this).css({visibility:'visible'}); } }); });