My scenario is quite simple. I have a few checkboxes and I want to check whether they are checked or not.
Now I'm using the following:
@Html.CheckBox("chkColour")<br />
<input type="checkbox" name="chkColourCoding" value="Colour Coding" />Colour coding<br />
<input type="checkbox" name="chkDoggyBars" value="Doggy Bars" />Doggy bars<br />
<input type="checkbox" name="chkLadderRacks" value="Ladder Racks" />Ladder racks<br />
<input type="checkbox" name="chkCabSliders" value="Cab Sliders" />Cab sliders<br />
<input type="checkbox" name="chkBrakeLights" value="Brake Lights" />Brake Lights<br />
<input type="checkbox" name="chkInteriorLights" value="Interior Lights" />Interior Lights<br />
<input type="checkbox" name="chkRubberising" value="Rubberising" />Rubberising<br />
<input type="checkbox" name="chkRoofRacks" value="Roof Racks" />Roof racks<br />
Now I googled almost two hours and I do not want to waste any more time on this. I've tried everything from
var check = document.getElementById('chkColourCoding');
if (check.checked)
{}
to
if($("#chkColourCoding").prop('checked'))
{}
and also
if($('.chkColourCoding').is(':checked'))
{}
Can someone please explain to me what is the difference and suggest why something why this is not working? Do I need to do some referencing to use jQuery