I have tried everything and nothing works. I have this checkbox
<input type="checkbox" onchange="WriteFormSelections('SearchForm', 'AccommodationType', 'AccommodationTypeSelections', 'All', 'AccommodationType-0', false, '_', true);" value="Hotel" name="AccommodationType_Hotel" id="AccommodationType-2">Hotel And I want to check it when the page loads. I have tried lots of things. One of the things I can't work out is, am I supposed to use the id or the name of the checkbox to check it?
Here's my current code. I have tried to use prop as suggested by this post but that doesn't work either.
<script type="text/javascript"> $('AccommodationType-2').attr('checked', true); </script>
$('AccommodationType-2')is looking for DOM elements of type<AccomodationType-2>, you probably meant$('#AccommodationType-2')(ID selector) or$('.AccommodationType-2')(class selector).