요소(=태그) 추가


요소(=태그) 추가

** HTML 또는 UI에 요소를 동적으로 추가할 수 있다. 1. `append()`: 선택한 요소의 내부 마지막 부분에 새로운 요소나 내용을 추가합니다. <script> $(document).ready(function(){ $("button").click(function(){ $("ol").append("<li>New List item</li>"); }); }); </script> <body> <ol> <li>List item</li> <li>List item</li> <li>List item</li> </ol> <button>클릭하면 리스트를 추가해 줄게!</button> </body> 2. `prepend()`: 선택한 요소의 내부 처음 부분에 새로운 요소나 내용을 추가합니다. <script> $(document).ready(function(){ $("button").click(function(){ $("ol").prepend("<li>New List item</li>"); }...


#after #요소추가 #요소_바로앞 #요소_바로뒤 #선택요소 #메서드 #동적 #내부처음 #내부마지막 #prepend #html #before #append #태그추가

원문링크 : 요소(=태그) 추가