javascript - jQuery invalid left-hand side error -


i'm receiving console error line:

$("#note" + notecount).val() = note; 

here full function:

function addnotes() {     notecount++;     var note = $("#noteinput").val();     console.log("note: " + note);     console.log("note count: " + notecount);     var display = document.createelement("div");     document.getelementbyid("displaycontainer").appendchild(display);     display.classname = "notedisplay";     display.id = "note" + notecount;     $("#note" + notecount).val() = note; } 

as can see i'm creating div id 'note' + note count i'm not sure how select change value.

better use textcontent property creating div

 var display = document.createelement("div");   display.id = "note" + notecount;  display.textcontent = note; 

or, .text() div doesn't have value property , need provide parameter method call:

$("#note" + notecount).text(note); 

as using jquery create html using it

var display = $("<div>", {     "text" : note,     "id" : "note" + notecount,     "class" : "notedisplay"      });  display.appendto('#displaycontainer'); 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -