JennyM
JennyM

Reputation: 95

How can I stop a check box getting clicked without disabling it

I am still having trouble with checkboxes. They are small and hard to see. When I disable my checkbox it becomes even harder to see. The color of the check becomes lighter.

Is there another way that I can stop a checkbox from responding to a click. Maybe something with javascript / jQuery so that once a variable is set then when a checkbox is clicked it just returns straight back to its pre-click state.

Upvotes: 0

Views: 583

Answers (2)

clyfish
clyfish

Reputation: 10460

<input type="checkbox" onclick="return false;" />

or with jquery:

html:

<input type="checkbox" class="disabled" />

js:

$('input.disabled').click(function(e) {
    e.preventDefault();
});

Upvotes: 0

Grant Thomas
Grant Thomas

Reputation: 45048

You could try using plain HTML with the readonly attribute:

<input type="checkbox" readonly="readonly" .../>

Upvotes: 1

Related Questions