append jquery objects why wont this work -
i'm trying write jquery in more object orientated way not working , can please help? result object object
$(document).ready(function () { var diva = $('<div>', { class: 'diva' }); var btn = $('<span>', { text: 'myspanbtn' }); btn.click(function(){ alert('test'); }); var divresult = $('<div>', { html: diva + btn }); $('#main').append(divresult); });
replace this:
var divresult = $('<div>', { html: diva + btn });
with this:
var divresult = $('<div>').append(diva, btn);
Comments
Post a Comment