0

I have this code below:

<div id="myid_info_barcode" class="myid_print_duo_barcode">
    <canvas width="256" height="256"></canvas>
</div>

I want to delete the canvas in runtime. How will I do that in Javascript?

Felix Kling
  • 795,719
  • 175
  • 1,089
  • 1,143
alyssaeliyah
  • 2,214
  • 6
  • 33
  • 80
  • 2
    Get a reference to it, maybe using *querySelector*. Then use `node.parentNode.removeChild(node)`. – RobG Jun 16 '15 at 02:25
  • 1
    It's not a "JavaScript element". JavaScript does not have elements. It's a "DOM element". –  Jun 16 '15 at 03:30

1 Answers1

0

With jQuery you can

$('#myid_info_barcode').empty();

Alternatively with plain javascript

document.getElementById("myid_info_barcode").innerHTML = "";
  • 3
    Answers should not be provided that rely on major libraries that are not requested or tagged in the question (such as jQuery). – jfriend00 Jun 16 '15 at 02:42