Clayton Batchelor Clayton Batchelor -4 years ago 200
Javascript Question

javascript checkbox line-through

I am trying to do a school project. I have to make a list and after the checkbox is clicked supposed to be crossed off. I don't know Javascript yet and I'm still trying to figure it out. I am wondering why this isn't working.

function crossout(id) {
var box = document.getElementById(id); = "text-decoration: line-through";

<h1>Hello World!</h1>
<h3>Shopping List</h3>
<p id="box1">
<input type="checkbox" onclick="crossout"("box1") />
<p id="box2">
<input type="checkbox" onclick="crossout"("box2") />
<p id="box3">
<input type="checkbox" onclick="crossout"("box3") />

<script src="app.js" charset="utf-8"></script>

Answer Source

You have a typo in your checkboxes:


This should be:


Your original way set onclick only to "crossout".

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download