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

http://jsfiddle.net/nrebv/

$(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); 

fiddle demo


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -