본문 바로가기
카테고리 없음

JQuery 버튼 클릭시 html 태그 추가

by 인디코더 2018. 11. 1.

JS Jquery 버튼 누르면 html 태그 추가

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>Insert title here</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
var i=0;
$(document).ready(function(){
    $("input").click(function(){
        $("body").append("<div id='v"+i+"'>'"+111+"'</div>")
        i++;
    });
})
</script>
</head>
<body>
<input type="button" >
    <div></div>
</body>
</html>
cs


결과




반응형