Change CSS by jQuery

Hi all, I can not solve my problem with show/hide button by clicking on checkbox. I have tried JS , jQuery ( on example down here…) . Thanks you for advance.

     <script>
          $(function () {
           $(".myCheck").click(function () {
              if $(this).is(":checked")) {
                 $("#removeButton").css("display", "list-item");
              } else {
                 $("#removeButton").css("display", "none");
              }
           });
          });
     </script>



     <button id="removeButton" 
                 onclick="article_form.submit();">
                 <img src="icons/remove_icon.png" />
     </button>

What’s $this? You haven’t declared that variable anywhere, it doesn’t seem to exist in that code. I think you meant this, which is available inside the function.

You right DanCouper, that little mistake taken from PHP…, I already fixed it. But still the code is wrong and useless :frowning:

In jQuery it’s $(this). So it should be: if ($(this).is(":checked")) {

You also have two different id names

In the HTML
remove_button

In the script
removeButton

<button id="removeButton" onclick="article_form.submit();">
  <img src="icons/remove_icon.png" />
</button>

<input class="myCheck" type="checkbox">


$(function() {
  $(".myCheck").click(function() {
    if ($(this).is("input:checked")) {
      $("#removeButton").css("display", "list-item");
    } else {
      $("#removeButton").css("display", "none");
    }
    console.log($("#removeButton").css);
  });
});

Thank you all very much. I am new in jquery/JS so thats why these mistakes :-/ happends to me. After code correcting by your advices, code is working well .