PostIT

[JavaScript/jQuery] jQuery에서 Append & Remove 처리하기. 본문

Script/JavaScript

[JavaScript/jQuery] jQuery에서 Append & Remove 처리하기.

shun10114 2017. 2. 2. 11:00

# jQuery에서 Append & Remove 처리하기.


var html="";

html=

"<div class='col-sm-2' id='surveyIdDiv"+item.surveyId+"'>" +

"<div class='margin-bottom-10' name='surveyIdInBinding'>"+item.surveyId+"</div>" +

"<div class='margin-bottom-10' name='surveyNameInBinding'>"+item.surveyName+"</div>" +

"<div class='margin-bottom-10' name='surveyBtnInBinding'><button class='btn btn-danger' onclick='cancleBinding("+item.surveyId+")'>취소</button></div>" +

"</div>";


1.Prepend

$("#surveyBindingDiv").prepend(html);

//surveyBindingDiv에 자식노드맨 위에 들어간다.


2.Append

$("#surveyBindingDiv").append(html);

//surveyBindingDiv에 자식노드로 맨 아래 들어간다.


3.Remove

$("#surveyIdDiv"+surveyId).remove();

//#(id)값의 태그를 찾아서 지워준다.



Comments