<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="http://code.jquery.com/jquery.js"></script>
<style>
#box{
border: 1px solid red;
width: 200px;
height: 200px;
padding: 0;
}
.cardGroup{
border: 1px solid blue;
/* padding: 0;
margin: 0; */
}
.cardGroup li{
border: 1px solid green;
width: 200px;
height: 200px;
list-style: none;
margin: 0;
}
</style>
</head>
<body>
<div id="box">
<ul class="cardGroup">
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
</ul>
</div>
<script>
var _$2 = function(selector){
var dom = document.querySelectorAll(selector);
//var myQuery = new Obejct();
var myQuery = {};
if(dom){
myQuery.dom = dom;
myQuery.bgColor = function(color) {
for(var i=0; i<this.dom.length; i++) {
this.dom[i].style.backgroundColor = color;
}
}
return myQuery;
}
return null;
}
_$2("#box").bgColor("yellow");
_$2(".cardGroup li").bgColor("skyblue");
</script>
</body>
</html>
'2022 SW전문인재양성사업 > 웹 프로그래밍 기본' 카테고리의 다른 글
jQuery API (1) - 기초 (0) | 2022.08.02 |
---|---|
jQuery (4) - 장바구니 구현, localStorage (0) | 2022.08.01 |
jQuery (2) - callback (0) | 2022.08.01 |
jQuery (1) - 기초 (0) | 2022.08.01 |
socket.io를 이용한 데이터 전송 (양방향) (0) | 2022.07.29 |