0
$.ajax({
\t \t url:'/getArticles',
\t \t method:'GET',
\t }).done(function(articles){
\t \t var content = '';
\t \t articles.forEach(function(e){
\t \t \t var res = "<div class='article'>" +
\t \t \t \t \t \t "<h3>" + e.title + "</h3>" +
\t \t \t \t \t \t "<p>" + e.content + "</p><br>" +
\t \t \t \t \t \t "<button onclick=crud.remove(" + e._id + ")>Remove</button><br>" +
\t \t \t \t \t "</div>";
\t \t \t content += res;
\t \t });
\t \t $('#allarticles').append(content);
\t });
\t window.crud = (function(){
\t \t // Remove an article
\t \t function remove(id){
\t \t \t console.log(id);
\t \t }
e._id
를 삽입 할 문자열에 버튼 어린 아이 클릭 이벤트를 추가하려면?
내가 말하는이 버튼을 클릭하면 : jQuery를 사용하여 버튼 만들기에 구문 오류가 있습니다
(index):1 Uncaught SyntaxError: Invalid or unexpected token
는 따옴표로 매개 변수를 넣어 :' "<버튼의 onclick을 = \ "crud.remove ('"+ e._id +' ") \"> 제거
"' –