KiRa
KiRa

Reputation: 924

How to put an image inside a button that created in javascript?

I am developing a simple project using bootstrap. I have this code that can create a button inside a dataTable and it is working fine. I try to put an image to it not glyphicons by the code that I provided below as you can see.. But it's not working. But the glyphicon icon in First button is working.

{ data: "ActionMenu", title: "Test", sClass: "alignCenter","mRender": function (data) {
   return '<button type="button" class="btn btn-info btn-md action" id="checkId"><i class="fa fa-dollar fa-fw action"></i></button>'
   + '&nbsp; <button type="button" class="btn btn-danger btn-md action" id="checkId2" src="Images/TestPicture.png"></button>';
}

Upvotes: 0

Views: 429

Answers (2)

Lokesh_K
Lokesh_K

Reputation: 563

 <button id="imageId type="button"><img src="path/of/image"></button>

Appy css with the help of ID if required

Upvotes: 1

gobes
gobes

Reputation: 562

You can't give a src to a button element. Try to put an <img> element inside the button:

<button type="button" class="btn btn-danger btn-md action" id="checkId2">
    <img src="Images/TestPicture.png"/>
</button>

Upvotes: 1

Related Questions