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
Post a Comment