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?

2
  • 2
    Get a reference to it, maybe using querySelector. Then use node.parentNode.removeChild(node). Commented Jun 16, 2015 at 2:25
  • 1
    It's not a "JavaScript element". JavaScript does not have elements. It's a "DOM element". Commented Jun 16, 2015 at 3:30

1 Answer 1

0

With jQuery you can

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

Alternatively with plain javascript

document.getElementById("myid_info_barcode").innerHTML = "";
Sign up to request clarification or add additional context in comments.

1 Comment

Answers should not be provided that rely on major libraries that are not requested or tagged in the question (such as jQuery).

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.