the script changes the class and, accordingly, the background of the button. But does not change. Help! `
<script type="text/javascript"> $(function(){ $("#old").change(function(){ $(".but").toggleClass('active'); }); }); </script>` <style> .active{ background: #000000; } .but{ background: #00BFCD; border: none; } </style> <input type="checkbox" id="old" >go <button class="but">скачать</button>
$(function(){ ... });execute script on loading DOM elements$(document).ready(function() { ... });- Mr. Black$(function(){ ... })is a short form of the record$(document).ready(function() { ... })- Grundy$(function() { ... })is not a wrapper for jquery functions. Inside, an event handler is already assigned.change()- Mr. Black