Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can you concatenate two variables in jquery?

Can I do the following to concatenate two variables into one? Or there is a better way to do it?

   $('.row-add').live("click", function () {
          var newContent = $("<span>Example data</span>"+"");
          var newContent2 = $("<span>New Project</span>");
          var content = newContent+newContent2;
          $(this).closest("td").append(content);
        });
like image 592
wcdomy Avatar asked Dec 26 '22 17:12

wcdomy


1 Answers

You can use .add

content = newContent.add( newContent2 ); 
like image 181
aziz punjani Avatar answered Dec 29 '22 06:12

aziz punjani