Reputation: 339
convopic.addClass('convo-pic')
img.attr('src', base_url+'/assets/img/users/'+msg.server.profile_img)
convopic.html(img)
bubble.addClass('bubble startmsg')
bubble.text(msg.client.data.message)
$('.mydiv').html(convopic+bubble)
my expected output is
<div class="mydiv">
<div class="convo-pic">
<img src="'+base_url+'/assets/img/users/'+msg.server.profile_img+'"></img>
</div>
<div class="bubble startmsg">'+msg.client.data.message+'</div>
</div>
But it returns [object][object], any idea how handle 2 variables inside .html() ? I'm using this way to prevent xss.
Upvotes: 0
Views: 24
Reputation: 388416
You can use .add()
$('.mydiv').html(convopic.add(bubble))
or use .html()
and append()
$('.mydiv').html(convopic).append(bubble)
Upvotes: 1