sundries
3-20 $() 메소드 문서 객체 생성
스티브
2018. 1. 12. 21:03
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script src ="../js/jquery-3.2.1.js"></script>
</head>
<script>
// 결과가 나오지 않는다
// body 에 붙이는게 없기 때문에
$(function(){
$('<h1></h1>').html('Hello World..!');
//<h1>Hello World ..! </h1>
})
</script>
<body>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script src ="../js/jquery-3.2.1.js"></script>
</head>
<script>
//.appendTo('body') 를 하면 결과가 출력된다.
$(function(){
$('<h1></h1>').html('Hello World..!')
.appendTo('body');
//<h1>Hello World ..! </h1>
})
</script>
<body>
</body>
</html>