append()

html()의 차이점은 


append는 앞에 있는 것들을 살려주고 

html은 앞에 있는것들을 다 지우고 다시 쓰는듯함. 정확한지 모르겠네 여튼 

html쓰면 아래서 안됨. 


var barDiv = $('<div/>');

barDiv.attr('id', 'sidebar').html("<hr> <h2> why not!</h2>");


var btnDiv = $('<div/>');

btnDiv.attr('id', 'btnArea');

            

             $('#dataGridDiv').append(barDiv);

            $('#dataGridDiv').append(btnDiv);

            $('#dataGridDiv').append("<p>All new content. <em>You bet!</em></p>");




var barDiv = $('<div/>');

barDiv.attr('id', 'sidebar').html("<hr> <h2> why not!</h2>");


var btnDiv = $('<div/>');

btnDiv.attr('id', 'btnArea');

            

             $('#dataGridDiv').append(barDiv);

            $('#dataGridDiv').append(btnDiv);

            $('#dataGridDiv').html("<p>All new content. <em>You bet!</em></p>");




+ Recent posts