jquery create new div with using array value as id -


hi trying create new div using value array id

var divid = 'borough_'+boroughtagger.myidarray[intindex]; jquery('<div/>', {       id: divid   }).appendto('#results'); 

doesn't seem work ? ideas? update: removed comma line id: divid, <div></div> created no id property created.

from ive tried far following joes answer works: $('#results').append('');

ie div created : <div id="borough_2"></div>

i performing ajax call after creating div , wish do:

success: function(data){     // data retrived ok     var mydata = data;     $("boroughid=" + boroughtagger.myidarray[intindex]).html(mydata) } 

using joes method div created still cant reference append data recived ajax request. there scope problem perhaps?

try

$('#results').append('<div id="borough_'+ boroughtagger.myidarray[intindex] +'"></div>'); 

if want keep reference id, not problem, do

var divid = 'borough_'+ boroughtagger.myidarray[intindex]; $('#results').append('<div id="'+ divid +'"></div>'); 

you can access new element so:

$('#'+divid).dosomething(); 

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -