javascript - setting attributes of appended HTML to a variable in jquery? -


so, i'm working on backend create/edit/delete page blog - shows list of articles edit , delete button each. when edit button article 'foo' clicked, these things happen:

  • the div expands , raw html of edit form appended inside jquery append().

  • the dom has array of objects, each object containing information 1 article. specific object id 'foo' fetched , cast array 'bar'.

now, i'm trying set values of appended form values within 'bar'. i've tried using .attr(), .val(), nothing seems work.

i think problem might i'm doing in same scope. right after .append() call, try access elements appended id. tripping me up?

within function, how tried it:

$(this).parent().children('#thisone').append("<input id="articletitle">"); $(this).parent().children('#thisone').children('#articletitle').val("my title"); 

try building complete element before append it:

var $input = $("<input>", {      id: "articletitle",     value: "my title" });  $("#thisone").append($input); 

Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -