<!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>
</head>
<body>
<h1>jQuery 실습 03</h1>
<div id="box">box</div>
<button id="changeBtn">Change</button>
<script src="http://code.jquery.com/jquery.js"></script>
<script>
var fish = ['오징어', '꼴뚜기', '대구', '명태', '거북이'];
var arr = fish.map(function(item, i, ar){
//console.log(item, i, ar);
return `<li>${item}</li>`;
});
$('#changeBtn').click(function(e){
$('#box').append('<ul>');
arr.forEach(function(item){
$('#box ul').append(item);
});
$('#box').append('</ul>');
});
</script>
</body>
</html>
'2022 SW전문인재양성사업 > 웹 프로그래밍 기본' 카테고리의 다른 글
jQuery API (5) - submit, focus, blur (0) | 2022.08.02 |
---|---|
jQuery API (4) - load (0) | 2022.08.02 |
jQuery API (2) - 기초2 (0) | 2022.08.02 |
jQuery API (1) - 기초 (0) | 2022.08.02 |
jQuery (4) - 장바구니 구현, localStorage (0) | 2022.08.01 |