javascript - Jquery multi to do list accordion -


i using jquery accordion, java script , html5, trying make each section lists name. within section make can add or remove list in section. can see doing here fiddle.

i think problem here:

function add_listitem(key,item) {     var li = document.createelement('li');     li.appendchild(document.createtextnode(item));     li.setattribute("data-key,key");     var = document.createelement('button');     but.appendchild(document.createtextnode('delete'));     but.onclick = remove_item;     li.appendchild(but);     document.getelementbyid('todo_list').appendchild(li); } 

it working single to-do list. can not seem work. maybe i'm tired. appreciated.

looks need assign functions object.

here fiddle attaches them window (not good) fires event.

i suggest create javascript object can call functions on

code:

 $('#add').click(function () {      var listnames = prompt("please enter list name", "list 1");      $('#accordion').append('<h3><a href="#">' + listnames + '</a></h3><div id="' + listnames + '"><input onkeypress="javascript: if (event.keycode==13) window.add_items();" type="text" id="new_item" class="todo-input" placeholder="add list"></div>');      $("#accordion").accordion('destroy').accordion();  });  window.add_items = function add_items(){      //alert(this.document.activeelement.parentnode.id);      var new_item = this.document.activeelement;      alert(new_item.value);      var key = new date(); 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -