본문바로가기
현재위치 > COMMON > javascript

javascript

common.js

  • $( 'ul#gnb li a.depth_01' ).click( function( e ) {
    	if( $( this ).next().is( 'ul' ) ) {
    		e.preventDefault();
    		if(jQuery.type( window.innerWidth ) === "undefined" ) { // lte IE 8
    			$( 'ul#gnb li ul' ).toggleClass( 'gnb_li_ul_toggle' );
    		} else {
    			if( window.innerWidth >= 990 ) {
    				$( 'ul#gnb li ul' ).toggleClass( 'gnb_li_ul_toggle' );
    			} else {
    				$( 'ul#gnb li ul' ).css( 'display' , 'none' );
    				$( this ).next( 'ul' ).css( 'display' , 'block' );
    			}
    		}
    	}
    } );
    
    • jQuery.type( window.innerWidth ) - 스크롤 유 · 무와 관계없이 브라우저 전체 크기를 리턴
      • IE8 이하에서는 작동하지 않기 때문에 브라우저 버전 확인용으로 사용
    • 참고 : $( window ).width() - 스크롤 크기를 제외한 브라우저 전체 크기(스크롤 유 · 무에 따라 수치가 다름)
  • $( 'div.icon_link ul li:nth-child(4) a' ).css( {
    	'border-left' : 'none',
    	'border-right' : '1px solid #cccccc'
    } );
    
    • 자바스크립트로 css 다중 속성 적용하기 예시