0

Iam trying to place two image tags with different images/src values init, but in the end two image tags have been appended with same src value instead of different. May i know what s wrong with append:

$("<div/>", {
  "id": 'card'+i,
  "class": blockArr[k],
  html: $("<img src='"+key+"'/><img src='_ls-global/layout-images/layout2.png'/>")

}).appendTo("#gtable");

Any ideas ?

Thanks

3 Answers 3

2

Try this,

$("<div/>", {
  "id": 'card'+i,
  "class": blockArr[k],
}).html("<img src='"+key+"'/><img src='_ls-global/layout-images/layout2.png'/>")
  .appendTo("#gtable");
Sign up to request clarification or add additional context in comments.

Comments

0

You can supply plain HTML in this case:

Demo

$("<div/>", {
  id: 'card'+i,
  class: blockArr[k],
  html: "<img src='"+key+"'/><img src='_ls-global/layout-images/layout2.png'/>"
}).appendTo("#gtable");

Comments

0
$('#someDiv').append('<img src='someurl1' />');
$('#someDiv').append('<img src='someurl2' />');

Just use the append function

Comments

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.