0
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.

1 Answer 1

1

You can use .add()

$('.mydiv').html(convopic.add(bubble))

or use .html() and append()

$('.mydiv').html(convopic).append(bubble)
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you it works. I will mark this as a correct answer after the time limit :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.