{"id":961,"date":"2024-04-15T17:49:11","date_gmt":"2024-04-15T08:49:11","guid":{"rendered":"http:\/\/inwelly.com\/?p=961"},"modified":"2024-04-22T05:06:22","modified_gmt":"2024-04-21T20:06:22","slug":"javascript-li-%ed%83%9c%ea%b7%b8-node-%ec%bb%a8%ed%8a%b8%eb%a1%a4-on-bootstrap-%ec%b6%94%ea%b0%80-add-%ec%82%ad%ec%a0%9c-delete","status":"publish","type":"post","link":"https:\/\/inwelly.com\/?p=961","title":{"rendered":"JAVASCRIPT li \ud0dc\uadf8 node \ucee8\ud2b8\ub864 on bootstrap &#8211; \ucd94\uac00 add ,\uc0ad\uc81c delete"},"content":{"rendered":"\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>&lt;input type=button onclick=&#8221;AddContentsList()&#8221; value=&#8221;TEST BTN&#8221;&gt;&nbsp;<\/p>\n\n\n\n<p>&lt;input type=button onclick=&#8221;DelCtsList()&#8221; value=&#8221;DEL ALL&#8221;&gt;<\/p>\n\n\n\n<p>&lt;input type=button onclick=&#8221;DelCtsEachList(&#8216;1&#8217;)&#8221; value=&#8221;DEL EACH&#8221;&gt;<\/p>\n\n\n\n<p>&lt;div class=&#8221;col-12&#8243;&gt;<\/p>\n\n\n\n<p>&lt;ul class=&#8221;list-group&#8221; id=&#8221;ctsListBox&#8221; name=&#8221;ctsListBox&#8221; &gt;<\/p>\n\n\n\n<p>&lt;\/ul&gt;<\/p>\n\n\n\n<p>&lt;\/div&gt;<\/p>\n\n\n\n<p>&lt;script&gt;<\/p>\n\n\n\n<p>function AddContentsList()<\/p>\n\n\n\n<p>{<\/p>\n\n\n\n<p>var ul = document.querySelector(&#8220;#ctsListBox&#8221;);<\/p>\n\n\n\n<p>var text = &#8220;TEST LIST&#8221;;<\/p>\n\n\n\n<p>var add_classname = $(&#8220;#CLASSNAMD&#8221;).val();<\/p>\n\n\n\n<p>var button = document.createElement(&#8220;button&#8221;);<\/p>\n\n\n\n<p>button.innerHTML = &#8220;X&#8221;;<\/p>\n\n\n\n<p>button.addEventListener(&#8216;click&#8217;, function() {DelCtsEachList(add_classname);},false);<\/p>\n\n\n\n<p>&nbsp; var li = document.createElement(&#8220;li&#8221;);<\/p>\n\n\n\n<p>&nbsp; \/\/ Add Bootstrap class to the list element<\/p>\n\n\n\n<p>&nbsp; li.classList.add(&#8220;list-group-item&#8221;);<\/p>\n\n\n\n<p>&nbsp; li.classList.add(add_classname);<\/p>\n\n\n\n<p>&nbsp; li.appendChild(document.createTextNode(text+&#8221; &#8220;+add_classname));<\/p>\n\n\n\n<p>&nbsp; li.appendChild(button);<\/p>\n\n\n\n<p>&nbsp; ul.appendChild(li);<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<p>function DelCtsEachList(ABC)<\/p>\n\n\n\n<p>{<\/p>\n\n\n\n<p>$(&#8220;.&#8221;+ABC).detach();<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<p>function DelCtsList()<\/p>\n\n\n\n<p>{<\/p>\n\n\n\n<p>var cell = document.getElementById(&#8220;ctsListBox&#8221;);&nbsp;<\/p>\n\n\n\n<p>while ( cell.hasChildNodes() ) { cell.removeChild( cell.firstChild ); }<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<p>&lt;\/script&gt;<\/p>\n<\/blockquote>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"541\" height=\"351\" src=\"http:\/\/inwelly.com\/wp-content\/uploads\/2024\/04\/image-481.png\" alt=\"\" class=\"wp-image-962\" style=\"width:920px;height:auto\"\/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>&lt;input type=button onclick=&#8221;AddContentsList()&#8221; value=&#8221;TEST BTN&#8221;&gt;&nbsp; &lt;input type=button onclick=&#8221;DelCtsList()&#8221; value=&#8221;DEL ALL&#8221;&gt; &lt;input type=button onclick=&#8221;DelCtsEachList(&#8216;1&#8217;)&#8221; value=&#8221;DEL EACH&#8221;&gt; &lt;div class=&#8221;col-12&#8243;&gt; &lt;ul class=&#8221;list-group&#8221; id=&#8221;ctsListBox&#8221; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1279,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-961","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript"],"_links":{"self":[{"href":"https:\/\/inwelly.com\/index.php?rest_route=\/wp\/v2\/posts\/961","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/inwelly.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/inwelly.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/inwelly.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/inwelly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=961"}],"version-history":[{"count":1,"href":"https:\/\/inwelly.com\/index.php?rest_route=\/wp\/v2\/posts\/961\/revisions"}],"predecessor-version":[{"id":963,"href":"https:\/\/inwelly.com\/index.php?rest_route=\/wp\/v2\/posts\/961\/revisions\/963"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/inwelly.com\/index.php?rest_route=\/wp\/v2\/media\/1279"}],"wp:attachment":[{"href":"https:\/\/inwelly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=961"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/inwelly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=961"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/inwelly.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=961"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}