Go/html Show/hide div when checkbox is selected

I asked myself the following question with interface we can populate a dropdown but can we do this code in full go

<!DOCTYPE html>
<html>
<head><script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> 
</head>
<body> 
<script type="text/javascript">
$(document).ready(function () {
    $("#chk").click(function () {
        if ($(this).is(":checked")) {
            $("#dvS").show();
        } else {
            $("#dvPassport").hide();
        }
    });
});
</script>
<div class="checkbox">
<br>
<label style="padding-right:0px;"><input type="checkbox" name="cod" value="1" id="chk"> My shop  
<b>Candy/b></label>
</div>

 <select name="" id="dvS" style="display: none">
      <option value="">caramel</option>
      <option value="">lollipop</option>
      <option value="">Chocolat</option>
  </select>

thank you for your suggestions and help for a beginner

the question is can we do if else the code show not use the jquery or javascript?

I’m pretty sure the question is if it is possible to get rid of the jquery/javascript and use just go to show and hide the a div.

I can’t think of an easy way to do it.

thank you for your answer and sorry for my English aproximatif but the idea was there

Alternatively you can do this with Angular (although it is overkill).

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.