common.js
1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
$(document).ready(function() {
// リンクボックス
$('.linkBox').click(function() {
if($(this).find('a').attr('target') == "_blank"){
window.open($(this).find('a').attr('href'));
return false;
}
window.location = $(this).find('a').attr('href');
return false;
});
// スムーススクロール
$('a[href^="#"]').click(function(){
var speed = 500;
var href = $(this).attr("href");
var target = $(href == "#" || href == "" ? 'html' : href);
var position = target.offset().top;
$("html, body").animate({scrollTop:position}, speed, "swing");
return false;
});
// タブ
$('.tab li a').click(function(){
var id = $(this).attr("href");
$('.tab li').removeClass("active");
$(this).parent('li').addClass("active");
$('.tabContents > div').css("display","none");
$('.tabContents').find(id).css("display","block");
});
// アコーディオン
$('.acctit').click(function(){
$(this).next('.accodion').slideToggle();
if($(this).hasClass("open")){
$(this).removeClass("open");
}else{
$(this).addClass("open");
}
});
// ハンバーガーメニュー
$('#spMenu').click(function(){
$('#navigation').toggleClass("open");
});
$('.menu-close').click(function(){
$('#navigation').toggleClass("open");
});
// 子メニュー
$('#navigation nav > ul > li').mouseenter(function(){
var index = $(this).index();
if(index == 2){
$('ul.child').css("display", "block").css("opacity", 1).css("z-index", 99);
}else{
$('ul.child').css("display", "none").css("opacity", 0).css("z-index", -1);
}
});
$('#navigation nav > ul > li').mouseleave(function() {
$('ul.child').css("display", "none").css("opacity", 0).css("z-index", -1);
});
});