append(), appendTo(), html(), prepend(), prependTo(), text()
after(), before(), insertAfter(), insertBefore()
unwrap(), wrap(), wrapAll(), wrapInner()
detach(), empty(), remove(), unwrap()
참고 링크 3
replaceAll(), replaceWith()
addClass(), hasClass(), removeClass(), toggleClass()
val()
EX) append
<head>
...
<script src="http://code.jquery.com/jquery-3.2.1.min.js"></script>
<style>
p{ background: tomato; }
</style>
</head>
<body>
<p id="user_p">jQuery는 : </p>
<script>
$('p').append("<strong>재미있다</strong>");
// document.getElementById("user_p").innerHTML=document.getElementById("user_p").textContent + "<strong>재미있다</strong>";
</script>
</body>
EX2) after
<head>
...
<script src="http://code.jquery.com/jquery-3.2.1.min.js"></script>
</head>
<body>
<p>jQuery는 : </p>
<script>
$("p").after("<strong>재미있다</strong>")
</script>
</body>
EX) wrap
<head>
...
<script src="http://code.jquery.com/jquery-3.2.1.min.js"></script>
<style>
div {
border:2px blue solid;
margin:2px;
padding:2px;
}
p {
background:yellow;
margin:2px;
padding:2px;
}
strong {
color:red;
}
</style>
</head>
<body>
<span>Span Text</span>
<strong>What about me?</strong>
<span>Another one</span>
<script>
$("span").wrap("<div><div><p><em> </em></p></div></div>")
</script>
</body>
EX) remove
<head>
...
<script src="http://code.jquery.com/jquery-3.2.1.min.js"></script>
<style>
p{ background: tomato; margin: 6px 0; }
</style>
</head>
<body>
<p>Hello</p>
how are
<p> you?</p>
<button>call remove() </button>
<script>
$("button").click(function(){
$("p").remove();
});
</script>
</body>
EX) replace
<head>
...
<script src="http://code.jquery.com/jquery-3.2.1.min.js"></script>
<style>
p{ background: powderblue; margin: 6px 0; }
</style>
</head>
<body>
<p>Hello</p>
<p>JavaScript</p>
<p>World</p>
<script>
$("<b>jQuery</b>").replaceAll("p");
</script>
</body>