sundries
1-22 jQuery 충돌 방지
스티브
2018. 1. 11. 20:14
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script src ="../js/jquery-3.2.1.js"></script>
<style>
.high-light{background:orange;}
.append::before{content:'※' }
.append::after{content:'※'}
</style>
<!--
jQuery 외에 여러 플러그인을 사용할 때 $ 식별자가 충돌이 발생할 수 있음
이런 충돌을 방지 하기 위해 noConflict()메소드를 사용함
그러면 더이상 jQuery의 식별자로 $ 사용할 수 없음.
-->
</head>
<script>
$.noConflict(); //더이상 jQuery 의 식별자로 $를 사용할 수 없음
var j = jQuery; //jQuery 객체를 다른 변수에 저장해서 사용함
//jQuery 를 사용
j(function(){
alert('출동 방지 예제');
j('h1').removeClass('high-light'); //클래스 속성 제거
j('h1').addClass('append');//클래스 속성 추가
});
</script>
<h1 class="high=light">item - 0</h1>
<body>
</body>
</html>